public function checkFulfillmentSettings($orderId)
 {
     $order = new Cart66Order($orderId);
     $data = array();
     foreach ($order->getItems() as $item) {
         $data[] = $item->product_id;
     }
     $orderFulfillment = new Cart66OrderFulfillment();
     $orderF = $orderFulfillment->getModels();
     $notify = new Cart66AdvancedNotifications($orderId);
     foreach ($orderF as $of) {
         $products = array_filter(explode(',', $of->products));
         if (array_intersect($data, $products) || empty($products)) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] THEY INTERSECT!");
             $notify->sendOrderFulfillmentEmails($of->id);
         }
     }
 }
  	      '<?php 
            echo $order->ship_state;
            ?>
',
  	      '<?php 
            echo $order->ship_country;
            ?>
'
  	    ]);
  	  /* ]]> */
      </script>  
    <?php 
        }
        ?>
    <?php 
        foreach ($order->getItems() as $item) {
            ?>
      <?php 
            $product->load($item->product_id);
            $price = $item->product_price * $item->quantity;
            ?>
      <tr>
        <td>
          <?php 
            if (Cart66Setting::getValue('display_item_number_cart')) {
                ?>
            <span class="cart66-receipt-item-number"><?php 
                echo $item->item_number;
                ?>
</span>
          <?php 
Example #3
0
 public static function awardCommission($orderId, $referrer)
 {
     global $wpdb;
     if (!empty($referrer)) {
         $order = new Cart66Order($orderId);
         if ($order->id > 0) {
             $subtractAmount = 0;
             $discount = $order->discountAmount;
             $order_items = array();
             foreach ($order->getItems() as $item) {
                 $order_items[] = $item->item_number;
                 $price = $item->product_price * $item->quantity;
                 if ($price > $discount) {
                     $subtractAmount = $discount;
                     $discount = 0;
                 } else {
                     $subtractAmount = $price;
                     $discount = $discount - $price;
                 }
                 if ($subtractAmount > 0) {
                     $price = $price - $subtractAmount;
                 }
                 // Transaction if for commission is the id in th order items table
                 $txn_id = $order->trans_id;
                 $sale_amount = $price;
                 $item_id = $item->item_number;
                 $buyer_email = $order->email;
                 if (function_exists('wp_aff_award_commission')) {
                     // Make sure commission has not already been granted for this transaction
                     $aff_sales_table = $wpdb->prefix . "affiliates_sales_tbl";
                     $txnCount = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM {$aff_sales_table} where txn_id = %s", $txn_id));
                     if ($txnCount < 1) {
                         wp_aff_award_commission($referrer, $sale_amount, $txn_id, $item_id, $buyer_email);
                     }
                 }
             }
             // valid order id
             // Transaction if for commission is the id in th order items table
             $txn_id = $order->trans_id;
             $sale_amount = $order->total - ($order->shipping + $order->tax);
             // set eligible amount to total sans shipping
             $item_id = implode(',', $order_items);
             $buyer_email = $order->email;
             // Affiliate Royale
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "]\n         Running wafp_award_commission\n\n         referrer {$referrer}\n\n         sale_amount {$sale_amount}\n\n         txn_id {$txn_id}\n\n         item_id {$item_id}\n\n         buyer_email {$buyer_email}");
             do_action('wafp_award_commission', $referrer, $sale_amount, $txn_id, $item_id, $buyer_email);
         }
     }
 }