Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * eBay Pixel Tracking Code for WooCommerce
- * @author : eBay / PeppermintJamNetwork
- * @author : Imperative Ideas (@imperativeideas)
- * @description : A modified version of the eBay Tracking Code for use with WooCommerce 2.x
- */
- // Enter your product ID below (IMPORTANT)
- $pid = "";
- /** DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING **/
- $order_id = $_GET['order'];
- $order = new WC_Order($order_id);
- $items = $order->get_items();
- //order discount total
- $discount = $order->get_order_discount();
- //Begin the output, replace iframe with <pre> in order to see result w/o sending
- $output = '<iframe src="https://t.pepperjamnetwork.com/track?';
- $output .= "PID=$pid"; // gets the product ID variable
- $output .= "&INT=ITEMIZED"; // This is so eBay understands the formatting
- $i = 1; //Start the counter and iterate per product in the loop
- foreach( $items as $item ) {
- if ( $item['product_id'] > 0 ) { // We should replace this with !empty()
- $quantity = $item['qty']; // Get data from the order
- $price = $item['line_total']; // Get data from the order
- if ( !empty($item['variation_id']) ) { // Check for a product variation
- $id = $item['variation_id']; // Assign variation ID
- } else {
- $id = $item['product_id']; // Else use base ID
- }
- // Get the SKU based on the product ID (order does not tell us this information)
- $productmeta = new WC_Product($id);
- $sku = $productmeta->post->sku;
- //add_qty($quantity);
- $output .= '&ITEM' . $i . '=' . $sku; // write SKU to output
- $output .='&QTY'.$i.'='. $quantity; // write quantity to output
- if ($i == 1 && $discount) { // Check for a coupon & calculate
- $returnprice = $price - $discount;
- $output .='&TOTALAMOUNT'.$i.'='. $returnprice;
- } else {
- $output .='&TOTALAMOUNT'.$i.'='. $price;
- }
- $i++; //increase the counter
- }
- }
- $output .='&OID='.$order_id; // Output order ID
- $output .='" width="1" height="1" frameborder="0"></iframe>'; // Close iframe (or <pre> if echoing)
- echo $output; // Echo result
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement