/**
  * main action
  */
 public function mainAction()
 {
     return true;
     $order_id = (int) $this->GET['order_id'];
     if ($order_id == 0) {
         return true;
     }
     $Order = new ecommerce_order();
     $Order->setCacheable(false);
     $order_data = $Order->getFullDetail($order_id);
     if ($order_data['transaction']['id'] > 0) {
         $this->tpl->parse('content.button');
         if ($this->GET['resend_email'] == 'yes') {
             // implement in your installation
             onxshopGoto("/backoffice/orders/{$order_data['id']}/detail");
         }
     }
     return true;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     if (!is_numeric($this->GET['order_id'])) {
         msg("Onxshop_Controller_Component_Ecommerce_Gift_Voucher_Generate: order_id isn't numeric");
         return false;
     }
     $order_id = $this->GET['order_id'];
     if ($gift_voucher_product_id = $this->getGiftVoucherProductId()) {
         /**
          * get order detail
          */
         require_once 'models/ecommerce/ecommerce_order.php';
         $EcommerceOrder = new ecommerce_order();
         $EcommerceOrder->setCacheable(false);
         $order_detail = $EcommerceOrder->getFullDetail($order_id);
         /**
          * find if the order contains gift
          */
         if ($voucher_basket_items = $this->getVoucherBasketItems($order_detail, $gift_voucher_product_id)) {
             return $this->generateVouchers($voucher_basket_items);
         }
     }
     return true;
 }
Beispiel #3
0
 /**
  * getOrderDetail
  */
 public function getOrderDetail($order_id)
 {
     if (!is_numeric($order_id)) {
         return false;
     }
     require_once 'models/ecommerce/ecommerce_order.php';
     $Order = new ecommerce_order();
     $order_detail = $Order->getFullDetail($order_id);
     return $order_detail;
 }
 /**
  * Try to reward inviting user in referreal system
  * 
  * @param  int $order_id Order to check
  * @return boolean If attempt was successfull
  */
 public function rewardInvitingUser($order_id)
 {
     // get order detail
     require_once 'models/ecommerce/ecommerce_order.php';
     $EcommerceOrder = new ecommerce_order();
     $EcommerceOrder->setCacheable(false);
     $order_detail = $EcommerceOrder->getFullDetail($order_id);
     // get promotion detail
     $code = pg_escape_string($this->getPromotionCodeForOrder($order_id));
     $promotions = $this->listing("code_pattern = '{$code}'");
     $promotion = $promotions[0];
     if (substr($promotion['code_pattern'], 0, 4) === "REF-") {
         $usage = $this->getCountUsageOfSingleCode($code) + 1;
         // check if a user is not already rewarded
         $this->setCacheable(false);
         $rewarded_codes = $this->listing("generated_by_order_id = {$order_id}");
         if (count($rewarded_codes) == 0) {
             // automatically extend to 20 invites
             if ($promotion['uses_per_coupon'] > 0 && $usage > $promotion['uses_per_coupon'] && $usage < 20) {
                 $promotion['uses_per_coupon'] += 10;
                 $this->updatePromotion($promotion);
             }
             $data = array('title' => "Referral voucher code", 'description' => '', 'publish' => 1, 'type' => 3, 'code_pattern' => $this->generateRandomCode('REW-', 5, 5), 'discount_fixed_value' => $promotion['discount_fixed_value'], 'discount_percentage_value' => 0, 'discount_free_delivery' => 0, 'uses_per_coupon' => 1, 'uses_per_customer' => 1, 'limit_list_products' => '', 'other_data' => NULL, 'limit_delivery_country_id' => 0, 'limit_delivery_carrier_id' => 0, 'limit_by_customer_id' => $promotion['generated_by_customer_id'], 'limit_to_first_order' => 0, 'limit_to_order_amount' => $promotion['limit_to_order_amount'], 'generated_by_order_id' => $order_id, 'generated_by_customer_id' => $order_detail['basket']['customer_id']);
             $this->insert($data);
             $invited_customer_id = $order_detail['basket']['customer_id'];
             $rewarded_customer_id = $promotion['generated_by_customer_id'];
             $code = $data['code_pattern'];
             $this->sendRewardEmail($invited_customer_id, $rewarded_customer_id, $code, $usage);
             // send warning email when 15 invites reached
             if ($usage == 15) {
                 $this->sendWarningEmail($rewarded_customer_id);
             }
             return true;
         }
     }
     return false;
 }