0
Ich arbeite an etwas Code, um die ausgewählte Variation Preis * Menge zum Gesamtpreis zu erhalten.Get Qty * Variation Preis
Irgendwie schaffe ich nicht, um es arbeiten:
add_action('woocommerce_single_product_summary', 'woocommerce_total_product_price', 31);
function woocommerce_total_product_price() {
global $woocommerce, $product;
// let's setup our divs
echo sprintf('<div id="product_total_price" style="margin-bottom:20px; display: block;">%s %s</div>',__('Totaal Prijs:','woocommerce'),'<span class="price">'.$product->get_price().'</span>');
?>
<script>
jQuery(function($){
var price = <?php get_post_meta(get_the_ID(), '_regular_price', true);?>
console.log(price);
var currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
$('[name=quantity]').change(function(){
var product_total = parseFloat(price * this.value);
$('#product_total_price .price').html(currency + product_total.toFixed(2));
});
});
</script>
<?php }
Irgendwelche Vorschläge auf diesem?
Dont sollten Sie '$ this.val()' statt 'this.value' benutzen? –
Sie haben Recht, haben dies getan, aber es scheint, dass es das falsche Objekt braucht. Wenn ich Parseint hinzufüge, ist es keine Zahl. – Pjelp
'$ (this) .text();' oder '$ (this) .attr (" value ")' hängt vielleicht von Ihrer jquery-Version ab –