WordPress codex: apply_filters – clarification on creating a new hook on the fly. How do we use it?

How to use the filter single_product_archive_thumbnail_size I’ve searched for the tag single_product_archive_thumbnail_size in woocommerce repository on github. There is only the single occurrence of it as you see here. So how do we use it? The author’s of WooCommerce added this filter so that other developers would be able to modify the product’s archive thumbnail … Read more

How to remove recurring totals information for a particular subscription product? [closed]

Try filtering the hook woocommerce_cart_calculate_fees. Use this code. it might work for you. add_filter( ‘woocommerce_cart_calculate_fees’, ‘add_recurring_postage_fees’, 10, 1 ); function add_recurring_postage_fees( $cart ) { if ( ! empty( $cart->recurring_cart_key ) ) { remove_action( ‘woocommerce_cart_totals_after_order_total’, array( ‘WC_Subscriptions_Cart’, ‘display_recurring_totals’ ), 10 ); remove_action( ‘woocommerce_review_order_after_order_total’, array( ‘WC_Subscriptions_Cart’, ‘display_recurring_totals’ ), 10 ); } }

Migrate WooCommerce Orders [closed]

The reason copying those messed up your site was probably because of id mismatches. That is, posts with the ids of the stuff you’re importing already exists. Regardless, since woocommerce stores orders as a custom post type, your safest bet here is probably the built in wordpress post import/export tool. 1. In the wordpress backend … Read more

Woocommerce Membership Expiry Date

According to the documentation, wc_memberships_get_user_memberships() returns a list of WC_Memberships_User_Membership objects. The WC_Memberships_User_Membership class has a get_end_date() method that will return the expiry date. So you should be able to do something like this: // Get memberships for the current user. $memberships = wc_memberships_get_user_memberships(); // Verify that they have some memberships. if ( $memberships ) … Read more

How do I add a “Cancel” button on the subscriptions listing page [closed]

I was looking for the same thing but couldn’t find it anywhere so I tried to do it myself. Here’s my code by the way. Hope this helps. function addCancelButton($subscription) { $actions = wcs_get_all_user_actions_for_subscription( $subscription, get_current_user_id() ); if(!empty($actions)){ foreach ( $actions as $key => $action ){ if(strtolower($action[‘name’]) == “cancel”){ $cancelLink = esc_url( $action[‘url’] ); echo … Read more

Username field is not shown in Woocommerce’s registration contact form

I just fund the tricky solution, it was very simple and I did think about it. I just went to WooCommerce -> Settings -> Accounts and I untick the checkbox for “Automatically generate username from customer email”. I got the solution from this topic but here the problem was the contrary: https://stackoverflow.com/questions/32781569/remove-username-field-registration-form-woocommerce

How to modify “[Product] has been added to your cart” in WooCommerce?

add_filter( ‘wc_add_to_cart_message’, ‘my_add_to_cart_function’, 10, 2 ); function my_add_to_cart_function( $message, $product_id ) { $message = sprintf(esc_html__(‘« %s » has been added by to your cart.’,’woocommerce’), get_the_title( $product_id ) ); return $message; } The above code will help you to change the message. Since by knowing the hook wc_add_to_cart_message you can improve the code