Incorrect swatch location on more complex layouts
-
Hello!
You are using thewoocommerce_single_product_summaryhook with different priority values to control the swatch placement. While this works for basic themes that use the default WooCommerce template, it’s not a good solution. More advanced themes, like Blocky, use custom templates and provide multiple content blocks that can be reordered from the Customizer. Other plugins can also extend these templates.Because you use the same hook for everything, just with a different priority, the swatches do not display in the correct location on more advanced layouts when the Position is set to either Above or Below the Add to Cart button.
To fix this, please edit your
class-linked-variation.phpfile and replace the lines below:if( 'above_the_add_to_cart_button' === $alv_settings_positions ){
$this->loader->add_action( 'woocommerce_single_product_summary', $plugin_admin, 'show_link_variations', 25 );
}
if( 'under_the_add_to_cart_button' === $alv_settings_positions ){
$this->loader->add_action( 'woocommerce_single_product_summary', $plugin_admin, 'show_link_variations', 35 );
}with this new code snippet:
if( 'above_the_add_to_cart_button' === $alv_settings_positions ){
$this->loader->add_action( 'woocommerce_before_add_to_cart_form', $plugin_admin, 'show_link_variations', 5 );
}
if( 'under_the_add_to_cart_button' === $alv_settings_positions ){
$this->loader->add_action( 'woocommerce_after_add_to_cart_form', $plugin_admin, 'show_link_variations', 5 );
}By using the proper hooks, the swatches will display correctly across all themes, including those with custom templates or extended by third-party plugins.
You must be logged in to reply to this topic.