phpwordpresswoocommercebundlehook-woocommerce

Move WooCommerce Bundle Product add to cart section above short description


I'm using a plugin named WooCommerce product bundle and want to move for bundled products the single add to card template above the excerpt (short description).

I guess it's implemented by this code:

add_action( 'woocommerce_after_single_product_summary', 'wc_pb_template_add_to_cart_after_summary', -1000 );

But if I use remove_action in my theme's functions.php file, it's not working. When I removed it from the original file in wc-pb-template-hooks.php it worked.

So after it I want to add it to the Product Summary, but it's not working. Can somebody help, even by telling how to remove it from After Summary? What am I doing wrong?


Solution

  • To move single add to cart location above the product short description for bundle products, use the following instead:

    add_action( 'woocommerce_single_product_summary', 'change_single_add_to_cart_bundle_location', 1 );
    function change_single_add_to_cart_bundle_location(){
        global $product;
    
        if ( $product->is_type('bundle') ) {
            remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
            add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 15 );
        }
    }
    

    Code goes in functions.php file of your child theme (or in a plugin).

    Tested and works on Storefront theme and WordPress base themes (with the standard layout and default form location in the "Bundled Products" tab settings).