Comments 10Shelley started the conversationJuly 9, 2020 at 2:51pmOn the thank you page I am trying to do a quantity count on a custom woocommerce thank you page for the custom pinterest ads tracking.I have written some PHP code to count the quantity but it counts bundles with an extra count.i.e. Bundle of 2 products is quantity 3 - 2 for the individual items and 1 for the bundle. I need to basically do Total Quantity - # of bundles = Quantity of items soldAny idea how to count up if the bundle is present? Or at least what is the name of your custom post type - is it just 'bundle' ?This is what I have thus far:$sumofitems = 0; foreach ( $order->get_items() as $item_id => $item ) { $quantity = $item->get_quantity(); $sumofitems+=$quantity; } ?> <script> pintrk('track', 'checkout', { order_id: '<?php echo $order_id_number ?>', value: '<?php echo $totalamount ?>', order_quantity: '<?php echo $sumofitems ?>', currency: 'USD', em: '<?php echo wp_get_current_user()->user_email ?>' }); 767Janilyn repliedJuly 10, 2020 at 3:35amHi Shelley, Thank you for contacting WPClever Support Forum. 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 since we're having very heavy workloads at the moment. Best regards.Janilyn T. - WPClever Support Agent 1,227Dustin repliedJuly 16, 2020 at 12:10amHi Shelley,I'm so sorry for the late reply!In the loop: foreach ( $order->get_items() as $item_id => $item ) {}You can count the bundles or bundled products by using the code below: $bundles = $bundled = 0; foreach ( $order->get_items() as $item_id => $item ) { if ( $item->get_meta( '_woosb_parent_id' ) ) { // count bundled products $bundled += $item->get_quantity(); } if ( $order_item->get_meta( '_woosb_ids' ) ) { // count bundles $bundles += $item->get_quantity(); } } Best regards,Dustin Sign in to reply ...
On the thank you page I am trying to do a quantity count on a custom woocommerce thank you page for the custom pinterest ads tracking.
I have written some PHP code to count the quantity but it counts bundles with an extra count.
i.e. Bundle of 2 products is quantity 3 - 2 for the individual items and 1 for the bundle. I need to basically do
Total Quantity - # of bundles = Quantity of items sold
Any idea how to count up if the bundle is present? Or at least what is the name of your custom post type - is it just 'bundle' ?
This is what I have thus far:
$sumofitems = 0;
foreach ( $order->get_items() as $item_id => $item ) {
$quantity = $item->get_quantity();
$sumofitems+=$quantity;
}
?>
<script>
pintrk('track', 'checkout', {
order_id: '<?php echo $order_id_number ?>',
value: '<?php echo $totalamount ?>',
order_quantity: '<?php echo $sumofitems ?>',
currency: 'USD',
em: '<?php echo wp_get_current_user()->user_email ?>'
});
Hi Shelley,
Thank you for contacting WPClever Support Forum.
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 since we're having very heavy workloads at the moment.
Best regards.
Janilyn T. - WPClever Support Agent
Hi Shelley,
I'm so sorry for the late reply!
In the loop:
You can count the bundles or bundled products by using the code below:
Best regards,
Dustin