get product attributes for current product and store it in a variable

get_terms() Retrieves the terms in a given taxonomy or list of taxonomies. What you need is get_the_terms() Retrieves the terms of the taxonomy that are attached to the post. So you can simply replace $brand_terms = get_terms( ‘pa_liquor-brands’ ); with $brand_terms = get_the_terms( $post, ‘pa_liquor-brands’ ); And that should to the trick. You can read … Read more

Can’t set proper WooCommerce language translation [closed]

After installing WordPress version 4.6.1 and WooCommerce version 2.6.6, both with the default enabled language, English (United States), I followed the steps below and had the translation successfully installed and working: Set a language for your WordPress installation Click on the General sub-menu item under Settings from the Dashboard of your WordPress installation, and scroll … Read more

WooCommerce single product edit flexslider settings

After a little digging through the source I found there is a filter called woocommerce_single_product_carousel_options that can be used to modify the flex slider options for example: function my_product_carousel_options($options) { $options[‘animation’] = ‘fade’; return $options; } add_filter(“woocommerce_single_product_carousel_options”, “my_product_carousel_options”, 10);

Move payment options at checkout in WooCommerce [closed]

You can customize the checkout page using hooks. To remove the payment options add the following code to your (child)theme’s functions.php: remove_action( ‘woocommerce_checkout_order_review’, ‘woocommerce_checkout_payment’, 20 ); To add it after the order notes use this hook: add_action( ‘woocommerce_after_order_notes’, ‘woocommerce_checkout_payment’, 20 );

WP_Query for WooCommerce Products

<ul class=”products”> <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); wc_get_template_part( ‘content’, ‘product’ ); endwhile; } else { echo __( ‘No products found’ ); } wp_reset_postdata(); ?> </ul><!–/.products–>

Correct function to get the user’s latest Woocommerce Subscription?

use this code $users_subscriptions = wcs_get_users_subscriptions($user_id); retrieve the data using foreach foreach ($users_subscriptions as $subscription){ if ($subscription->has_status(array(‘active’))) { echo $subscription->get_id(); } } There is some function to access subscription data. like get_id(),get_date(‘end’) (to get last date of subscription ). I hope its help you well.

wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?

As mentioned in the comments, wc_get_template_part() tries to locate and load the requested template file. These template files could be ether in the /woocommerce/ sub-directory of a child-theme, or defined in another third party plugin (with the help of woocommerce_locate_template filter hook). If none of these exists, WC loads the default template file from /plugins/woocommerce/templates/ … Read more

Query WooCommerce orders grouped by several order statuses

The documentation on wc_get_orders and WC_Order_Query is poor… Now regarding the order status in a WC_Order_Query, you can pass an array of order statuses: // Display “completed” orders count $statuses = [‘completed’]; $orders = wc_get_orders( [‘limit’ => -1, ‘status’ => $statuses] ); echo ‘<p>’ . sprintf( __(‘Count of “%s” orders: %s’), implode(‘”, “‘, $statuses), count($orders) … Read more