Skip to content

Commit 98d9f90

Browse files
committed
Fix addToCart value for facebook
1 parent 95379ef commit 98d9f90

2 files changed

Lines changed: 69 additions & 135 deletions

File tree

includes/integrations/class-integration-facebook.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,16 @@ public function add_to_cart_ajax() {
146146
<script type="text/javascript">
147147
jQuery(function($) {
148148
$(document).on('added_to_cart', function (event, fragments, dhash, button) {
149+
var currencySymbol = $($(button.get()[0]).closest('.product')
150+
.find('.woocommerce-Price-currencySymbol').get()[0]).text();
151+
152+
var price = $(button.get()[0]).closest('.product').find('.amount').text();
153+
var originalPrice = price.split(currencySymbol).slice(-1).pop();
154+
149155
wcfbq('<?php echo $facebook_pixel_id ?>', 'AddToCart', {
150156
content_ids: [ $(button).data('product_id') ],
151157
content_type: 'product',
158+
value: originalPrice,
152159
currency: '<?php echo get_woocommerce_currency()?>'
153160
});
154161
});

0 commit comments

Comments
 (0)