• swapot

    (@swapot)


    I am trying to move Product Variations, which I believe are in ‘woocommerce_before_variations_form’, on Single Product Page to above the Product Title, Price, and everything else in the ‘woocommerce_single_product_summary’. See Image.

    Image of Woocommerce Hooks on Single Product Page

    The code I have tried is:

    
    function move_variations(){ ?>
      </div>
      <div class="summary entry-summary">
    <?php }
    add_action('woocommerce_before_variations_form', 'move_variations', 1);
    

    Placed at the bottom of my child theme’s function.php file.

    It is moving the Variations and everything below them (buy buttons, description) to below the main product image.

    Anyone know what I need to fix?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @swapot,

    Thanks for your query.

    Variations dropdown sticks together with add-to-cart button. You can move them along from Appearance > Customize > WooCommerce > Single Product > Layout > General > Elements.

    Here is the screenshot for your visual guide: https://i.snipboard.io/bToz1H.jpg

    Thread Starter swapot

    (@swapot)

    Hi Kharis,

    I see why it has been challenging to accomplish what I want. Since I posted the code above, I got help with a better version that almost accomplishe

    function 
    kia_relocate_variable_add_to_cart() {
        global $product;
    	
        if ( $product->is_type( 'variable' ) ) {
    		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', 1 );
        }
    }
    add_action( 'woocommerce_before_single_product', 'kia_relocate_variable_add_to_cart' );

    This snippet does has been tested to move the variations dropdown above the fields in ‘woocommerce_single_product_summary’. However, in Botiga theme it duplicates the variations dropdown content and the add to cart button.

    A developer who was helping me asked if my theme was a FSE theme.

    What I want to do is have the Product Title and Price be in between the Variations and Add to Cart button. In this order:

    1. Variations
    2. Product Title
    3. Price
    4. Add to Cart

    Is there a way this can be achieved?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Move (woocommerce_before_variations_form) above (woocommerce_single_product_sum)’ is closed to new replies.