I am trying to change placement of Price from top to beside the Add to Cart button and want to wrap Price and Add to cart button (form) both with one div.
I dont know either it is bad way or correct way but somehow I managed to change placement but now getting trouble to wrap both with
Here what I am doing
//first removing all from single product summary
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
// adding and re arranging placement
function q2a_product_summary() {
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
echo '<div class="buy-box">';
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
echo '</div>';
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
}
add_action('woocommerce_single_product_summary', 'q2a_product_summary');
But when I am adding it is throwing at the top like <div class="buy-box"> </div>
Now what should I do so I can wrap price and add to cart button with the div above.
Okay I solved this but don’t know it is right way or wrong way. Hope you expert will give some better guideline.
What I did just added two function into my add_action function and use those as a wrapper.
Is it only and correct way to do? I am sure there must be a better way than this long and messy way.
Please suggest.
I just added those 2 in the theme functions: