skip to Main Content

Move WooCommerce Product Variations and Cart Button To Sidebar

This little snippet will remove the variation and add to cart button from the single product summary and place it in the sidebar instead. You must have a sidebar enabled for the products (select your WooCommerce product layout in the Customizer). Because you will display the variations and add to cart button in the sidebar it won't have the same styling as the default so you must add custom CSS to make it look how you want it to.

function myprefix_woo_product_sidebar_attributes() {

	// Remove items from summary
	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

	// Add items to sidebar
	if ( is_singular( 'product' ) ) {
		add_action( 'wpex_hook_sidebar_inner', 'woocommerce_template_single_add_to_cart', 1 );

add_action( 'wp', 'myprefix_woo_product_sidebar_attributes' );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)
Back To Top