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

Where can I find a single item template

The WC single item template is located at: yoursite.com/wp-content/plugins/woocommerce/templates/single-product.php See this documentation: https://docs.woocommerce.com/document/template-structure/ So, you would want to move any of those templates to your child theme under /wp-content/themes/your-child-theme/woocommerce/[any_template_you_want] So, for example, if you wanted to edit the single-product.php but safe from WC updates, you would put the file in this directory and do your … Read more

Custom URL for each product variation – rewrite rules

Ok, for anyone looking for this, here’s a complete plugin that I came up with, that solves the issue: <?php /* Plugin Name: WooCommerce Variations URL Description: Adds support for variation-specific URL’s for WooCommerce product variations Author: Václav Greif Version: 1.0 Author URI: https://wp-programator.cz */ namespace WCVariationsUrl; final class Init { /** * Call this … Read more

WooCommerce showing star rating review instead of text review string

Suffered with same problem. Finally after lot of search and trial I came up with this solution. This gets the template where the rating is displayed from. But it displays like this: Rated 4.50 out of 5 based on 2 customer ratings (2 customer reviews) <div class=”rating-custom”> <?php wc_get_template( ‘single-product/rating.php’ ); ?> </div> Then paste … Read more