Woocommerce - special field within the jquery and use split handlers

Asked

Viewed 11 times

-1

I’m in a personal project, and I’m having a hard time understanding how jquery works in Woocommerce, I use Woocommerce as a quotation system and I’m trying to generate a dynamic presentation price table >>without integration (I won’t save the data in the BD )<< with the Woocommerce system, I just want a presentation table on the product page that uses the data captured from the store as price and some attributes. What I have so far is the code below:

<script>
jQuery(function($) {
    var pc = 'p.price' //preco de custo
        q = $(pc).html();

    $('form.cart').on('show_variation', function( event, data ) {
        if ( data.price_html ) {
            $(pc).html(data.price_html); // mostra o valor
        }
    }).on('hide_variation', function( event ) {
        $(pc).html(q);
        
    });
});
</script>

On the Woocommerce product page I have to capture the product price (the code above already does this) and make a formula with the attribute fields "pa_custo" and "pa_qdy"

the formula I would like to apply to this code would be

Product price $(pc) + ("pa_cost" / (split) "pa_qdy") = x

Could someone please help me?

1 answer

0

If selectors are classes would be in this example:

  var ex = parseFloat($('.price').val()) + (parseFloat($('.pa_custo').val()) / parseFloat($('.pa_qdy').val());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.