Let’s say you want to show Optional and mandatory accessories before the related products and not at the bottom. Then you can use the following code inside your child theme functions.php:

Mandatory accessories:

remove_action( 'woocommerce_after_single_product_summary', array( $WooCommerce_Product_Accessories->plugin_public, 'woocommerce_mandatory_accessories_display' ), 25 );
add_action( 'woocommerce_after_single_product_summary', array( $WooCommerce_Product_Accessories->plugin_public, 'woocommerce_mandatory_accessories_display' ), 5 );

Optional Accessories:

remove_action( 'woocommerce_after_single_product_summary', array( $WooCommerce_Product_Accessories->plugin_public, 'woocommerce_optional_accessories_display' ), 30 );
add_action( 'woocommerce_after_single_product_summary', array( $WooCommerce_Product_Accessories->plugin_public, 'woocommerce_optional_accessories_display' ), 5 );

5 Is the new position for both elements.

5 thoughts on “Change product accessories Position

  1. Daniel Henningsson says:

    Hello,

    How can I change to get the optional accessories after the product description? With your code above it gets displayed before the product description.

  2. jake says:

    How do I put the mandatory accessories in a tab? I’ve tried so many ways but nothing works. 🙁

    //add tabs
    add_filter(‘woocommerce_product_tabs’, ‘woo_new_product_tab’);

    function woo_new_product_tab($tabs)
    {

    global $post;
    $tech_specs_data = get_field(“tech_specs”);
    $product_specs_data = get_field(“product_specs”);
    $video_tab_data = get_field(“video_tab”);
    $included_items_tab_data = array($WooCommerce_Product_Accessories->plugin_public, ‘woocommerce_mandatory_accessories_display’);

    // Adds the new tab

    if (!empty($product_specs_data)) {

    $tabs[‘product_specs’] = array(
    ‘title’ => __(‘Packing List’, ‘woocommerce’),
    ‘priority’ => 15,
    ‘callback’ => ‘woo_new_product_specs_content’
    );
    }

    if (!empty($included_items_tab_data)) {
    $tabs[‘included_items_tab_data’] = array(
    ‘title’ => __(‘Replacement Parts’, ‘woocommerce’),
    ‘priority’ => 20,
    ‘callback’ => ‘woocommerce_optional_accessories_display’
    );
    }

    if (!empty($tech_specs_data)) {
    $tabs[‘tech_specs’] = array(
    ‘title’ => __(‘Technical Data’, ‘woocommerce’),
    ‘priority’ => 25,
    ‘callback’ => ‘woo_new_tech_specs_content’
    );
    }

    if (!empty($video_tab_data)) {
    $tabs[‘video_tab’] = array(
    ‘title’ => __(‘Tutorial Video’, ‘woocommerce’),
    ‘priority’ => 35,
    ‘callback’ => ‘woo_new_video_tab_content’
    );
    }

    return $tabs;

    }

    function woo_new_product_specs_content()
    {

    echo get_field(“product_specs”);

    }

    function woo_new_tech_specs_content()
    {

    echo get_field(“tech_specs”);

    }

    function woo_new_video_tab_content()
    {

    echo get_field(“video_tab”);

    }

    function woo_new_included_items_tab_content()
    {
    echo array( $WooCommerce_Product_Accessories->plugin_public);

    }

    add_action( ‘woo_new_included_items_tab_content’, array( $WooCommerce_Product_Accessories->plugin_public, ‘woocommerce_optional_accessories_display’ ), 5 );

  3. Stuart says:

    Hi
    I would like to display the accessories within one of the product tabs, ideally a custom tab I have created. Is there a hook or something I can use to loop the connected accessories?

    Thanks
    Stuart

Leave a Reply

Your email address will not be published.