2 prices when using different variation prices

This topic has 4 replies, 2 voices, and was last updated 4 months ago ago by Luca Rossi

  • Avatar: carlyliczyk
    carliczyk
    Participant
    July 12, 2024 at 04:17

    Hello, I was kindly provided this code below to move the product price ontop of the add to cart page. But now when we use different prices for the variation’s theres 2 prices.

    Is there a way to only include 1 price, but still have it show ontop of the add to cart button?

    Thanks so much

    
    add_action('wp_footer', 'n2t_wp_footer');
    function n2t_wp_footer(){
        if(is_singular('product')){
    	?>
        <script>
            jQuery( function($){
                $(document).ready(function(){
                    $('[data-widget_type="woocommerce-product-etheme_price.default"]').insertBefore($("form.cart button.single_add_to_cart_button"));
                })
            });
        </script>
    	<?php
        }
    }
    
    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    July 12, 2024 at 08:04

    Dear Carly,

    We hope this message finds you well. Could you please provide further details on your objectives with the videos or screenshots you mentioned? We are currently unclear about your intentions.

    Thank you for your cooperation.

    Best Regards,
    8Theme’s Team

    Avatar: carlyliczyk
    carliczyk
    Participant
    July 12, 2024 at 16:17

    Sure no problem, video attached.

    When I select a variable product’s child with a different price, it displays 2 prices.

    I would like the variable product price to be displayed where the prices above the add to cart button is.

    Thanks

    Please contact administrator
    for this information.
    Avatar: Justin
    Luca Rossi
    Support staff
    July 13, 2024 at 11:43

    Hi @carlyliczyk,

    We could see that you’ve already have this code. So please extend this a little bit.

    – Change from:

    
    // On live event (attribute select fields change)
    $('table.variations select').on('blur', function() {
        // variation ID is selected
        if ('' != $(c).val() && $(a).text() != '') {
            $(d).html($(a).html());
            // We copy the variation description
        }// No variation ID selected
        else {
            $(d).html($(a).html());
            // We set back the variable product description
        }
        console.log($('input.variation_id').val());
        // TEST: Selected variation ID … To be removed
    });
    

    – To:

    
    // On live event (attribute select fields change)
    $('table.variations select').on('blur', function() {
        // variation ID is selected
        if ('' != $(c).val() && $(a).text() != '') {
            $(d).html($(a).html());
            // We copy the variation description
        }// No variation ID selected
        else {
            $(d).html($(a).html());
            // We set back the variable product description
        }
        $('[data-widget_type="woocommerce-product-etheme_price.default"] .price').html($('.woocommerce-variation-price').html());
        console.log($('input.variation_id').val());
        // TEST: Selected variation ID … To be removed
    });
    

    Please note that any issues with the custom codes are falled outside of scope our support standard services.

    Thanks for understanding!

    Best Regards,
    8Theme’s Team

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.