當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CI::GiftCards方法代碼示例

本文整理匯總了PHP中CI::GiftCards方法的典型用法代碼示例。如果您正苦於以下問題:PHP CI::GiftCards方法的具體用法?PHP CI::GiftCards怎麽用?PHP CI::GiftCards使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CI的用法示例。


在下文中一共展示了CI::GiftCards方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: submitGiftCard

 public function submitGiftCard()
 {
     //get the giftcards from the database
     $giftCard = \CI::GiftCards()->getGiftCard(\CI::input()->post('gift_card'));
     if (!$giftCard) {
         echo json_encode(['error' => lang('gift_card_not_exist')]);
     } else {
         //does the giftcard have any value left?
         if (\CI::GiftCards()->isValid($giftCard)) {
             $message = \GC::addGiftCard($giftCard);
             if ($message['success']) {
                 \GC::saveCart();
                 echo json_encode(['message' => lang('gift_card_balance_applied')]);
             } else {
                 echo json_encode($message);
             }
         } else {
             echo json_encode(['error' => lang('gift_card_zero_balance')]);
         }
     }
 }
開發者ID:alextoshinov,項目名稱:musymeshop,代碼行數:21,代碼來源:Cart.php

示例2: delete

 public function delete($id)
 {
     \CI::GiftCards()->delete($id);
     \CI::session()->set_flashdata('message', lang('message_deleted_gift_card'));
     redirect('admin/gift-cards');
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:6,代碼來源:AdminGiftCards.php

示例3: submitOrder

 function submitOrder($transaction = false)
 {
     foreach ($this->items as $item) {
         if ($item->type == 'gift card') {
             //touch giftcard
             \CI::GiftCards()->updateAmountUsed($item->description, $item->total_price);
             continue;
         } elseif ($item->type == 'coupon') {
             //touch coupon
             \CI::Coupons()->touchCoupon($item->description);
             continue;
         } elseif ($item->type == 'product') {
             //update inventory
             if ($item->track_stock) {
                 \CI::Products()->touchInventory($item->product_id, $item->quantity);
             }
             //if this is a giftcard purchase, generate it and send it where it needs to go.
             if ($item->is_giftcard) {
                 //process giftcard
                 $options = CI::Orders()->getItemOptions(GC::getCart()->id);
                 $giftCard = [];
                 foreach ($options[$item->id] as $option) {
                     if ($option->option_name == 'gift_card_amount') {
                         $giftCard[$option->option_name] = $option->price;
                     } else {
                         $giftCard[$option->option_name] = $option->value;
                     }
                 }
                 $giftCard['code'] = generate_code();
                 $giftCard['activated'] = 1;
                 //save the card
                 \CI::GiftCards()->saveCard($giftCard);
                 //send the gift card notification
                 \GoCart\Emails::giftCardNotification($giftCard);
             }
         }
     }
     if (!$transaction) {
         $transaction = $this->transaction();
     }
     //add transaction info to the order
     $this->cart->order_number = $transaction->order_number;
     $this->cart->transaction_id = $transaction->id;
     $this->cart->status = config_item('order_status');
     $this->cart->ordered_on = date('Y-m-d H:i:s');
     $orderNumber = $this->cart->order_number;
     $this->saveCart();
     //refresh the cart
     $this->getCart(true);
     //get the order as it would be on the order complete page
     $order = \CI::Orders()->getOrder($orderNumber);
     //send the cart email
     \GoCart\Emails::Order($order);
     //return the order number
     return $orderNumber;
 }
開發者ID:berkapavel,項目名稱:GoCart3,代碼行數:56,代碼來源:GoCart.php


注:本文中的CI::GiftCards方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。