Detect whether a page is a product subcategory page?

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 = get_queried_object_id(); } $cat = get_term(get_queried_object_id(), ‘product_cat’); if ( empty($cat->parent) ){ return false; }else{ … Read more

Limit users to one active subscription in WooCommerce Subscriptions? [closed]

Unless I’m misunderstanding you, WC Subscriptions already has this functionality. Firstly, set your subscription product to be variable or grouped, rather than having multiple individual products. Set the subscription product to limit purchasing: https://docs.woocommerce.com/document/subscriptions/store-manager-guide/#limit-subscription Then turn on allow switching: https://docs.woocommerce.com/document/subscriptions/switching-guide/#section-2 Hope that helps

Display orders instead of woocommerce my account dashboard for logged in users [closed]

How to redirect a user to my-account/orders correctly Try this: add_action( ‘parse_request’, ‘redirect_to_my_account_orders’ ); function redirect_to_my_account_orders( $wp ) { // All other endpoints such as change-password will redirect to // my-account/orders $allowed_endpoints = [ ‘orders’, ‘edit-account’, ‘customer-logout’ ]; if ( is_user_logged_in() && preg_match( ‘%^my\-account(?:/([^/]+)|)/?$%’, $wp->request, $m ) && ( empty( $m[1] ) || ! in_array( … Read more

How do I display certain products via their category on a section of a page using PHP?

you can still use a shortcode inside of php if you aren’t customizing the output. see https://docs.woocommerce.com/document/woocommerce-shortcodes/#scenario-5-specific-categories and https://developer.wordpress.org/reference/functions/do_shortcode/ <?php echo do_shortcode(‘[products category=”new-arrivals”]’); ?> Alternatively, If you need to customize the output of the products then just use wc_get_products to get a list of products and iterate through it. See https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query <?php $args = array( … Read more

How to get rid of the hover zoom in WooCommerce single products

This is possible using woocommerce_single_product_zoom_enabled dedicated filter hook: add_filter( ‘woocommerce_single_product_zoom_enabled’, ‘__return_false’ ); Code goes in functions.php file of your active child theme (or active theme). Tested and work. It is possible using woocommerce_single_product_zoom_enabled dedicated filter hook. The hook undocumented available parameters in the options array are: $zoom_options = array ( ‘url’ => false, ‘callback’ => … Read more

Process checkout using WC REST API

To process payment for an WooCommerce Order, the workflow goes like the following: Create an WooCommerce Order Process Payment for this order, using one of WC_Payment_Gateways Change order status (default is pending->processing, or to complete if empty order) IMHO, Step two can be implemented as the following: Use a front-end lib to tokenize payment info, … Read more