Add sub subpage endpoint in woocommerce

Thanks to @mmm and his comment defining $endpointsub before $endpoint it worked. Not sure why that is but that solved it. So change the order of endpoints: $endpointsub = ‘my-new-endpoint/new-subendpoint’; $endpoint=”my-new-endpoint”; add_rewrite_endpoint( self::$endpointsub, EP_ROOT | EP_PAGES ); add_rewrite_endpoint( self::$endpoint, EP_ROOT | EP_PAGES ); add_query_vars( $vars ) { $vars[] = self::$endpointsub; $vars[] = self::$endpoint; return $vars; … Read more

Apply Additional Discount after coupon

Put this code in your current theme function.php file. Set how many discount as per your require. function add_extra_discount( $cart ) { $discount = $cart->subtotal * 0.3; $cart->add_fee( __( ‘Extra Discount’, ‘twentyseventeen’ ) , -$discount ); } add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_discount’ );

Get the category ID in checkout page woocomerce

Getting the ids of the items in your cart can be done somewhat like this: global $woocommerce; $cart = $woocommerce->cart->get_cart(); $cart_items_ids = array(); foreach ( $cart as $item_key => $item_value ) { $cart_items_ids[] = $item_value[ ‘data’ ]->id; } OR Plese check below Snippet: Check if Product Category is in the Cart – WooCommerce add_action(‘woocommerce_before_cart’, ‘xyz_check_category_in_cart’); … Read more

Woocommerce exclude specific categories products from related products

add_action( ‘wp’, ‘vn_remove_related_products’ ); function vn_remove_related_products() { if ( is_product() && has_term( array(‘workshops’, ‘events’), ‘product_cat’ ) ) { remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 ); } } Function has_term() can pass first parameter as array with terms.

if statement for search results

Within the loop the best way to check if the result is a product would be to check the value of get_post_type(): if ( get_post_type() === ‘product’ ) { } As you say, is_woocommerce(), is_product() and is_search() are for checking which type of page is being viewed regardless of the current item in the loop.

Fatal Error in WordPress WooCommerce theme “Call to undefined function wc_get_theme_slug_for_templates()”

Ok, the error is telling you this: The error comes from this theme file: \themes\vw-ecommerce-shop\woocommerce\global\wrapper-end.php Line: 23. In that file on line 23 the following function is called wc_get_theme_slug_for_templates() but at that point it’s not (yet) available. The function should be available though, because it’s a valid Woocommerce function, see here. Can you update your … Read more

Hiding products with a specific tag from WooCommerce main shop page

You can paste the following snippet in your child theme’s functions.php function exclude_specific_tag( $q ) { if (is_shop()){ $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘pré-commande’ ), // write the tag name to remove in between the ” ‘operator’ => ‘NOT IN’ ); $q->set( … Read more