WooCommerce change price in cart [closed]

So the answer to this is instead of placing the code in your functions.php, you create a “woocommerce” folder in your theme folder, and place the “cart” folder and the “cart.php” template file from the woocommerce plugin inside of that. Then you place the same code as in the “woocommerce_before_calculate_totals” action inside the loop of … Read more

Set a default quantity input value for a variable product category in WooCommerce

On woocommerce_available_variation hook the $args array doesn’t include input_value argument. Also You are not using has_term() conditional function in the right way for product categories. So try the following code instead: add_filter( ‘woocommerce_available_variation’, ‘customizing_available_variation’, 10, 3 ); // Variations function customizing_available_variation( $args, $product, $variation ) { if( has_term( ‘flyer’, ‘product_cat’, $product->get_id() ) ) { $args[‘max_qty’] … Read more

Set a specific default stock quantity on all WooCommerce new products

For “New” simple products on admin, the following embedded jQuery script will: trigger and enable “Stock management” at product level, set the “Stock quantity” to “1”, set the “Low stock threshold” to “0”. The code: add_action( ‘admin_footer’, ‘new_product_stock_default_setting’ ); function new_product_stock_default_setting() { global $pagenow, $post_type; // Targeting new product page (admin) if( $pagenow === ‘post-new.php’ … Read more

Unable to programmatically remove product from WooCommerce cart

I guess you should use your function on the hook woocommerce_add_to_cart instead of template_redirect Your function works fine for me. Try an alternative methow which also works: add_action(‘template_redirect’, function () { $product_id = 29690; foreach( WC()->cart->get_cart() as $key=>$item){ if($item[‘product_id’]==$product_id){ WC()->cart->remove_cart_item( $key ); } } // $product_cart_id = WC()->cart->generate_cart_id( $product_id ); // $cart_item_key = WC()->cart->find_product_in_cart( $product_cart_id … Read more

Display a list subcategories under the main product category thumbnails?

Ok so after some more searching online and using the right combination of search terms I stumbled across this guide here: https://www.themelocation.com/how-to-display-all-the-subcategories-from-a-specific-category-in-woocommerce/ From that guide I created this snippet of code that can be added to your theme’s functions.php file so that the subcategory list appears under the main category title in the main categories … Read more