“Cannot read property ‘replace’ of undefined” Javascript error when trying to add attribute terms from add product page [closed]

The problem was a minor bug in the Variation Swatches for WooCommerce plugin, the add term modal html wasn’t being included in the add product page as a result of wrong conditional statement in the class-admin.php file on line 266: if ( $pagenow != ‘post.php’ || ( isset( $post ) && get_post_type( $post->ID ) != … Read more

Edit WooCommerce product content based on category

There’s a couple of ways to do it, you can edit the template file \woocommerce\templates\single-product\title.php directly and change your title format there. Otherwise, you can remove the WordPress hook in your functions.php file and add your own to override it which I borrowed from this answer <?php remove_action( ‘woocommerce_single_product_summary’,’woocommerce_template_single_title’, 5 ); add_action( ‘woocommerce_single_product_summary’, ‘modify_woocommerce_template_single_title’,5 ); … Read more

How to display empty stars on products with woocommerce?

Add the following code to your functions.php add_action(‘woocommerce_after_shop_loop_item_title’,’change_loop_ratings_location’, 2 ); function change_loop_ratings_location(){ remove_action(‘woocommerce_after_shop_loop_item_title’,’woocommerce_template_loop_rating’, 5 ); add_action(‘woocommerce_after_shop_loop_item_title’,’woocommerce_template_loop_rating’, 15 ); } And then after add the following lines also to get the rating count add_filter( ‘woocommerce_product_get_rating_html’, ‘loop_product_get_rating_html’, 20, 3 ); function loop_product_get_rating_html( $html, $rating, $count ){ if ( 0 < $rating && ! is_product() ) { global … Read more

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