Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3206920
Loop name to get custom code working with pop-up
Open

Comments

  • Axel Segebrecht started the conversation

    Similar to Janke’s question, I also like to know the loop name or any help you can give to those of us who need to add custom code for our customers 

    I’ve got a script that updates the total price shown on the product page when the user changes the quantity. Sadly, I can’t seem to get the script to fire in the modal.

    Click on a product on the homepage “View to add”; modal opens and you can see the “Total:” text on the right of the “Add to basket” button. The script is from: https://www.businessbloomer.com/woocommerce-calculate-subtotal-on-quantity-increment-single-product/

    Happy to pay and or buy the premium plug-in!

    The page I need help with: https://staging.butchersfridge.co.uk/

  •  767
    Janilyn replied

    Hi Axel,

    Thanks for contacting WPClever Support Forum. We're not available at the weekends so today (Monday) I am able to process your ticket.

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions as soon as possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  1,226
    Dustin replied

    Hi Axel,

    Please use the below custom code instead (How to add custom code?)

    add_action( 'woocommerce_after_add_to_cart_button', 'woosq_product_price_recalculate' );
    function woosq_product_price_recalculate() {
        global $product;
        $price = $product->get_price();
        echo '<div id="subtotal" data-price="' . esc_attr( $price ) . '" style="display:inline-block;">Total: </div>';
    }
    add_action( 'wp_footer', 'woosq_footer_js' );
    function woosq_footer_js() {
        $currency = get_woocommerce_currency_symbol();
        ?>
        <script>
          (function($) {
            $(function() {
              $('[name=quantity]').trigger('change');
            });
            $(document).on('woosq_loaded', function() {
              $('[name=quantity]').trigger('change');
            });
            $(document).on('input change', '[name=quantity]', function() {
              var qty = $(this).val();
              var price = $('#subtotal').data('price');
              var price_string = (price * qty).toFixed(2);
              $('#subtotal > span').html('<?php echo esc_js( $currency ); ?>' + price_string);
            });
          })(jQuery);
        </script>
        <?php
    }

    In the settings page of WPC Smart Quick View, please choose this option https://www.screencast.com/t/0qB5qkkVR

    Best regards,
    Dustin

  • Axel Segebrecht replied

    Thank you, Dustin.

    To clarify: I add the code to my functions.php replacing the existing one? My updated file now looks like the one I attached. While the product detail page works, the modal price change still doesn't. Maybe I got it wrong.

    Attached files:  functions.php.zip

  • Axel Segebrecht replied

    I now switched to a plugin called Final Price (https://codecanyon.net/item/final-price/7994706) which works well on product pages but not at all in the modal that WPC Smart Quick View is opening.

    Please help, I am happy to pay I just need to finish this for my customer.