• I’m trying to move the variable product description below the add to cart button. Woocommerce populates this automatically and handles toggling with product variation selections changes, but I can’t for the life of me
    find what hook or filter I’m supposed to used.

    I’m able to hook another custom function beneath the add to cart button. So I think my problem is not knowing the name of the hook and/or if it’s a hook versus a filter. Where should I start looking to accomplish this? Thanks!

    https://www.ads-software.com/plugins/woocommerce/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Please post a link to a relevant page.

    Thread Starter thenixus

    (@thenixus)

    Sorry for the delay: here’s a link to the site. Just to be clear, I’m trying to move the descriptions of the individual product variations, not the general product description!

    https://www.cchcollection.com.php53-13.ord1-1.websitetestlink.com/product/kenan-jacket

    It currently appears under the variation selectors and dynamically changes when you select a new variation, and I’d like to put them below the Add to Cart button.

    I think you are looking for hooks, not filters here.

    I don’t think variable product descriptions are part of WooCommerce. They seem to be coming from your “Improved variable product attributes” plugin. That and your theme are commercial products to which this forum’s members don’t have access. Not having any of the code is a handicap here.

    Consider downloading the wp-content directory contents to your hard drive where it can be searched with something like Agent Ransack. Search for hooks by searching for:
    ‘woocommerce_single_product_summary’
    Its likely that each element of the summary will be hooked separately, the priority argument of the hook giving the order in which the elements appear. The hooks may appear in WooCommerce’s wc-template-hooks.php, or something similar in your theme or plugin, or a combination, hence the need to do a text search.

    Moving elements is achieved by the remove_action function, using the same priority argument as used in the add_action function in the first place, then another add_action with a different priority argument.

    Thread Starter thenixus

    (@thenixus)

    Thanks for your reply.

    I’ve tried this with all plug-ins turned off (except WC) and on the Twenty Fifteen theme. The variable product description is available to a)edit under each individual variation as “Variation Description” and b)changes to what is typed in the “Variation Descriptions” field when I toggle different variations on an individual product page. I’m 99% sure it comes included in WC.

    I will, however, try to do the text search to find the hook.

    Thread Starter thenixus

    (@thenixus)

    I found where it’s added in WC default – woocommerce\assets\js\frontend\add-to-cart-variation.js

    The JS that then controls it (lines 522-528):

    var $single_variation_wrap = $form.find( '.single_variation_wrap' );

    $single_variation_wrap.prepend( $( '<div class="woocommerce-variation-description" style="border:1px solid transparent;">' + variation_description + '</div>' ).hide() );

    So it’s directly prepending into the .single_variation_wrap div, which contains the add to cart button, the price, and the variations description.

    I don’t think I’d be able to prevent that from hooking there unless I overwrote that JS file? Is there a cleaner way?

    I found the Variation Description field, thank you. Hadn’t spotted that before. Introduced in v2.4 apparently.

    I tried this function. The prepend in the js failed without error, why?, and the variation description was added to the new placeholder.

    add_action ('woocommerce_after_single_variation', 'my_function');
    function my_function() {
    ?>
    <div class="woocommerce-variation-description" style="border: 1px solid transparent; height: auto;"></div>
    <?php
    }

    Thread Starter thenixus

    (@thenixus)

    That totally worked! Thank you so much!

    Can you show me how you got this to work? I want to add the description to go below the variable product image. But I can’t figure out how. Any help appreciated. I have tried various filters but no show. Thanks

    I used the ‘woocommerce_product_thumbnails’ to put the variations-description placeholder after the thumbnails, but it was ignored by the javascript this time. So you would need to customise add-to-cart-variation.js to put the placeholder in the new place and also to put the descriptions in the new placeholder. I’ve not seen an update-safe way to customise javascripts, so this would need to be recoded after each update. Could be a lot of work for what it is.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Moving Variation Product Descriptions’ is closed to new replies.