New answers tagged

0

For me works this: add_action('init', 'myStartSession', 1); add_action('wp_logout', 'myEndSession'); add_action('wp_login', 'myEndSession'); function myStartSession() { if(!session_id()) { session_start(); } } add_action( 'woocommerce_order_status_completed', 'my_functiony4' ); function my_functiony4($order_id) { $order = new ...


0

I solved this, but maybe this isn't the most elegant solution: global $wpdb; $OrderItemMetaTable = $wpdb->base_prefix.'woocommerce_order_itemmeta'; $wpdb->update( $OrderItemMetaTable, array('order_item_id'=>$PreviousItemArrayKey), array('order_item_id'=>$key, 'meta_key'=>'pa_color'), array('%d'), array('%d', '%s') ); $wpdb->update( ...


0

woocommerce_order_status_completed fires once when an order is updated. It should not be used to output HTML. You need woocommerce_order_details_after_order_table: function wpse_227312_order_footer( $order ) { if ( ! $order->has_status( 'complete' ) ) return; ?> <script> opi_email = '<?php echo esc_js( ...


1

Quickie Run only when you need to run and only run where you need to run Your code is almost there but you are not running at the particular time,if we use the your code it runs first and then filtered again by WooCommerce. So we have two options. Change priority of the filter Hook the code to run properly I think just unsetting ...


0

I have added pagination in order history page and it is working. Replace below code above loop $customer_orders1 = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array( 'numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => wc_get_order_types('view-orders'), ...


0

I have added pagination in order history page and it is working. Replace below code above loop $my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array( 'order-number' => __( 'ID', 'woocommerce' ), 'order-date' => __( 'Date', 'woocommerce' ), 'order-total' => __( 'Packages', 'woocommerce' ), ...


-1

Can you please try below code? $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $woo_home_query = array( 'post_type' => 'product', 'posts_per_page' => $top_selling_products_nr, 'meta_key' => 'total_sales', 'paged' => $paged, 'orderby' => 'meta_value_num' ...


1

That is due to the fact, that your filter woocommerce_breadcrumb doesn't even exist. This filter here works and pulls out all the elements, that are currently in the breadcrumb (as an array): add_filter( 'woocommerce_get_breadcrumb', 'change_breadcrumb' ); function change_breadcrumb( $crumbs ) { var_dump( $crumbs ); return $crumbs; } And this ...


1

You can wrap it in the same check used for $category: <?php if (isset($term->term_id)) { echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>'; } ?> or check to make sure it is not an error object: <?php if (!is_wp_error($term)) { echo '<a href="'.get_term_link($term).'">'.$term->name.'</a>'; } ...


1

Use wp_login_url. <a href="<?php echo wp_login_url(); ?> ">login</a> To redirect to home page after login, add the $redirect argument and point to home_url() <a href="<?php echo wp_login_url( home_url() ); ?> ">login</a>


3

I think you are on the right track, wp_cache_delete was what finally helped me get an auto-signup with auto-login plugin working... I have this from there: wp_cache_delete($current_user->ID, 'users'); wp_cache_delete($current_user->user_login, 'userlogins'); Then see what roles you get after that with: $current_user = wp_get_current_user();


0

Yes you can for example target the link itself inside the trending id with CSS and remove the action with CSS itself, in your place it would be something like this: #trending > li.product > a { pointer-events: none; cursor: default; } Note that this is CSS scheme, not exact CSS, that deppends on classes you have (I would be more specific if ...


2

Have you tried logging in the user after your changes? Such as: wp_set_current_user( $current_user->ID, $current_user->user_login ); wp_set_auth_cookie( $current_user->ID ); do_action( 'wp_login', $current_user->user_login );


2

First add the following code (and probably the WC Test Payment Gateway) and do a test order to get a list of all the data keys that are set in the order process via the woocommerce_after_checkout_validation filter: add_action('woocommerce_after_checkout_validation','custom_modify_order',10,1); function custom_modify_order($posted) { foreach ($posted as ...


0

You can do that with css - the form is hidden by default, but can be targeted like this: .woocommerce-checkout form.checkout_coupon{ display:block } (put that in style.css)


0

To remove your search box as you want, the easiest way is to use CSS: #sidebar > form:first-of-type{display:none;} Here you are using pseudo selector that will remove only first form appearing in your sidebar and that is your search you want to remove.


2

is_category() only check the built in post category. Product categories are custom taxonomies. So you need to use is_tax() instead of is_category() and get_term() instead of get_category(). Check this example:- function is_subcategory($cat_id = null) { if (is_tax('product_cat')) { if (empty($cat_id)){ $cat_id = ...


1

You don't need to! With a little understanding of how URLs and query vars work, we can do this entirely within the URL of the page, with no additional PHP code First we have a URL: example.com/abc/123 Then we have a rewrite rule. The rule has a regex pattern that matches the URL, and a second bit that says were all the bits that match go, e.g. ...


1

A minor update (I ran into this issue today): The above solution does not work anymore. The only thing you need to do nowadays is to set the post_parent: wp_update_post(array( 'ID' => $booking->id, 'post_parent' => $order->id ));


-1

Finally solved the problem. The item wasn't being added because the product didn't have a price. That's all.


0

If anyone needs it $args = array( 'type' => 'product', 'parent' => get_queried_object_id(), 'orderby' => 'term_group', 'hide_empty' => true, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' ...


0

Found the answer here: http://code.tutsplus.com/tutorials/a-guide-to-overriding-parent-theme-functions-in-your-child-theme--cms-22623 <?php function child_remove_parent_function() { remove_action( 'woocommerce_before_main_content', 'mod_output_content_wrapper', 10 ); } add_action( 'wp_loaded', 'child_remove_parent_function' ); ?> Explanation is ...


2

As the keys already hold PHP generated output, it should be possible to simply wrap them in some MarkUp woocommerce_wp_select( array( 'id' => 'productstatus_select', 'label' => __( 'Product Status', 'woocommerce' ), 'options' => array( 'Message one' => sprintf( '<span ...


2

You can do in the following way! Create an array of CSS class names and message values $colors_stings = array( 'Message one' => 'message_color_green', 'Message two' => 'message_color_red', 'Message three' => 'message_color_blue' ); Check if message string exist in array then assign CSS color class to variable. $css_class = ...


2

Sorry I can not comment yet on this site Could you be removing an action before it is registered? Have you tried wrapping this with an on init hook? Perhaps using remove_filter would be a better choice. function my_init() { remove_filter( 'storefront_header', array( 'Galleria_Structure', 'galleria_top_bar_wrapper' ) ); remove_filter( ...


2

Ok I found out the solution. Because, as I said, WooCommerce has it's own hooks, first of all I've searched for a WooCommerce hook about registration. I discovered the existence of a hook very similiar to the one used by WordPress: woocommerce_registration_errors. Obviously it works in the same way. Then I simply replaced the WordPress hook with the ...


0

This is pretty common issue with translations. If you have downloaded po/mo woocommerce translation files, you probably put them now in wp-content/woocommerce/languages folder. Please if this is the case try to move them to global languages folder in wp-content/languages/plugins. Also note that if you are moving them to global folder they should look ...



Top 50 recent answers are included