当前位置: 首页>>代码示例>>PHP>>正文


PHP Money::fromPennies方法代码示例

本文整理汇总了PHP中Money::fromPennies方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::fromPennies方法的具体用法?PHP Money::fromPennies怎么用?PHP Money::fromPennies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Money的用法示例。


在下文中一共展示了Money::fromPennies方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIsGreaterThan

 public function testIsGreaterThan()
 {
     $base = Money::fromPennies(1000);
     $less = Money::fromPennies(999.99);
     $equal = Money::fromPennies(1000);
     $more = Money::fromPennies(1001);
     $this->assertFalse($less->isEqualOrGreaterThan($base));
     $this->assertFalse($less->isGreaterThan($base));
     $this->assertTrue($equal->isEqualOrGreaterThan($base));
     $this->assertFalse($equal->isGreaterThan($base));
     $this->assertTrue($more->isEqualOrGreaterThan($base));
     $this->assertTrue($more->isGreaterThan($base));
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:13,代码来源:MoneyTest.php

示例2: __construct

 /**
  * TestOrder constructor.
  * @param array $options
  */
 public function __construct($options = [])
 {
     if (!empty($options['items'])) {
         $this->items = array_replace($this->items, $options['items']);
     }
     if (!empty($options['address'])) {
         $this->address = array_replace($this->address, $options['address']);
     }
     if (!empty($options['payment'])) {
         $this->payment = array_replace($this->payment, $options['payment']);
     }
     if (!empty($options['y_cash'])) {
         $this->ycash = array_replace($this->ycash, $options['y_cash']);
     }
     if (!empty($options['card'])) {
         $this->card = array_replace($this->card, $options['card']);
     }
     if (!empty($options['party_id'])) {
         $this->party_id = $options['party_id'];
     }
     if (!empty($options['credits'])) {
         $this->credits = Money::fromPennies($options['credits']);
     }
     if (!empty($options['coupons'])) {
         $this->coupons = $options['coupons'];
     }
     if (!empty($options['replacement'])) {
         $this->replacement = $options['replacement'];
     }
     if (!empty($options['user_id'])) {
         $this->user_id = $options['user_id'];
     }
     if (!empty($options['presenter_id'])) {
         $this->presenter_id = $options['presenter_id'];
     }
     if (!empty($options['warehouse'])) {
         $this->warehouse = $options['warehouse'];
     }
     if (!empty($options['database'])) {
         $this->database = $options['database'];
     }
     if (!empty($options['expedited'])) {
         $this->expedited = $options['expedited'];
     }
     if (session_id() === "") {
         session_start();
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:52,代码来源:TestOrder.php

示例3: purchase

 public function purchase()
 {
     $this->Presenter->id = $this->data['sponsor_id'];
     $presenter = $this->Presenter->loadBasicDetails();
     if (!empty($presenter)) {
         $promoterId = 0;
         $presenterId = $presenter['Presenter']['id'];
     } else {
         $promoterId = 0;
         $presenterId = 0;
     }
     $validation_errors = array();
     $this->shoppingCart = new ShoppingcartController();
     if (empty($this->data['paypaluserid'])) {
         if (!strlen($this->data['billingCardholderFirstName']) || !strlen($this->data['billingCardholderLastName'])) {
             $validation_errors['cardHolder'] = array("The name on the card is required");
         }
         $credit_card_number = $this->data['cardNum'];
         if (!strlen($this->data['cardNum'])) {
             $validation_errors['cardNum'] = array("The credit card number is required");
         } else {
             $credit_card_number = preg_replace('/\\D/', '', $credit_card_number);
             //pgandhay if ( ! preg_match('/\d{13,16}/', $credit_card_number) || !$this->luhn_check($credit_card_number)) {
             if (!preg_match('/\\d{13,16}/', $credit_card_number) || !$this->shoppingCart->luhn_check($credit_card_number)) {
                 $validation_errors['cardNum'] = array("The credit card number is invalid");
             }
         }
         $credit_card_code = preg_replace('/\\D/', '', $this->data['cardCode']);
         if (!strlen($credit_card_code) || strlen($credit_card_code) < 3 || strlen($credit_card_code) > 4) {
             $validation_errors['cardCode'] = array("The card code is invalid");
         }
         if (!strlen($this->data['cardExpMonth']) || !strlen($this->data['cardExpYear'])) {
             $validation_errors['cardExpYear'] = array("The expiration date is required");
         } else {
         }
         switch ($this->data['sameAsShipping']) {
             case "on":
                 if (!strlen($this->data['postal_code'])) {
                     $validation_errors['postal_code'] = array("The billing postal code is required");
                 }
                 break;
             default:
                 //check for not empty
                 if (!strlen($this->data['billingState']) && $this->data['billing_market_id'] != Market::MARKET_UNITED_KINGDOM) {
                     $validation_errors['billingState'] = array("The billing state is required");
                 }
                 if (!strlen($this->data['billingZip'])) {
                     $validation_errors['billingZip'] = array("The billing postal code is required");
                 }
                 if (!strlen($this->data['billingEmail'])) {
                     $validation_errors['billingEmail'] = array("The billing email is required");
                 }
                 if (!strlen($this->data['billingAddress1'])) {
                     $validation_errors['billingAddress1'] = array("The billing address is required");
                 }
                 //validate
                 //					$this->Address->set('postal_code', $this->data['billingZip']);
                 //					if (!$this->Address->validates(array('fieldList' => array('postal_code'))))
                 //						$validation_errors['billingZip'] 		= array("Please use a valid billing postal code.");
                 $this->Email->set('email', $this->data['billingEmail']);
                 if (!$this->Email->validates(array('fieldList' => array('email')))) {
                     $validation_errors['billingEmail'] = array("Please use a valid billing email address.");
                 }
                 break;
         }
         if (!empty($validation_errors)) {
             $this->sendError(500, $validation_errors);
             return;
         }
     }
     if (empty($presenterId)) {
         $this->sendError(500, array("process_error" => array("Please choose a Presenter for your purchase")));
         return;
     }
     if (empty($this->request->data['items'])) {
         $this->sendError(500, array("process_error" => array("There are no items in your Shopping Cart")));
         return;
     }
     $itemIds = $this->request->data['items'];
     //$userId = $this->Session->read("user_id");
     $userId = $this->request->data['userId'];
     $party = $this->Party->partyFromId($this->data['party_id'], $presenterId, true);
     if (!empty($party)) {
         $partyId = $party['Party']['id'];
     } else {
         $partyId = 0;
     }
     if (!empty($this->request->data['cardExpMonth'])) {
         $this->request->data['cardExp'] = $this->request->data['cardExpMonth'] . "/" . $this->request->data['cardExpYear'];
     }
     /**
      * @var Money
      */
     $productCredits = null;
     if (!empty($this->request->data['productcredits'])) {
         $productCredits = Money::fromPennies((int) $this->request->data['productcredits']);
     }
     $commission_total = null;
     //determine if user is a presenter
     $is_presenter = $this->Presenter->presenterFromUserId($userId);
//.........这里部分代码省略.........
开发者ID:kameshwariv,项目名称:testexample,代码行数:101,代码来源:MController.php

示例4: _checkPromoAdjustments

 /**
  * Use this to calculate a value to be decremented from promo items due to ycash and HPI usage.
  *
  * If you change this function to match a kudo promo, save the existing code in the wiki with a
  * description so that it can be reused in the future
  *
  */
 private function _checkPromoAdjustments($items, $ycash = null, $qualifying_items = array())
 {
     //load the item model to get the price info on items
     App::import("Model", "Item");
     $this->Item = new Item();
     //get the productcredits
     $trigger_item = $this->Item->detailsBySku('US-1051-00');
     $trigger_item_price = (double) $trigger_item['price'];
     //$trigger_item = $this->Item->detailsBySku($qualifying_items);
     //get additional skus (sets, combos, etc) of qualifying items if applicable
     //Hard code collections since I am short on time
     $collections = array("US-41011-01", "US-41021-01", "US-41031-01", "US-41041-01", "US-41051-01", "US-41061-01", "US-91201-01");
     //to keep track of HPI in case of no ycash
     $total_qualifying_items = 0;
     $hpi_qty = 0;
     $count = 0;
     //contains the price value of trigger items in cart
     $qualifying_items_value = Money::fromFloat(0);
     //contains the price value of the non trigger items in the cart
     $total_adjusted_item_value = Money::fromFloat(0);
     $product_credits = Money::fromPennies($ycash);
     foreach ($items as $value) {
         $item_detail = $this->Item->detailsBySku($value['sku']);
         $price = $item_detail['price'];
         $coupons = (int) count(array_unique($value['coupons']));
         $qty = (int) $value['qty'];
         if (in_array($value['sku'], $qualifying_items)) {
             $count += $qty;
             $floor = $qty - $coupons;
             $total_qualifying_items += $floor > 0 ? $floor : 0;
             $hpi_qty += $coupons;
             $iteration_value = Money::fromFloat($trigger_item_price)->times($qty - $coupons);
             $qualifying_items_value->add($iteration_value);
         }
         //for collections containing trigger item, make the min allowed non coupon value equal to the trigger item price
         if (in_array($value['sku'], $qualifying_items) && in_array($value['sku'], $collections)) {
             $total_adjusted_item_value->add(Money::fromFloat($price)->times($qty));
             //reduce amount by items with HPI applied
             $total_adjusted_item_value->subtract(Money::fromFloat($price)->times($coupons));
         } else {
             $total_adjusted_item_value->add(Money::fromFloat($price)->times($qty));
             //reduce amount by items with HPI applied
             $total_adjusted_item_value->subtract(Money::fromFloat($price)->times($coupons));
         }
     }
     $commissionable = $total_adjusted_item_value->copy()->subtract($product_credits);
     if ($commissionable->amount > 0 && $ycash->amount > 0) {
         //don't want to divide by 0
         $divisor = $trigger_item_price == 0 ? 1 : $trigger_item_price * 100;
         $qualified_promo_qty = floor(($commissionable->amount - $ycash->amount) / $divisor);
         //			$qualified_promo_qty = "($commissionable->amount / 100) / $divisor)";
         return $qualified_promo_qty;
     } else {
         return $total_qualifying_items;
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:63,代码来源:CashAndCarry.php

示例5: prices

 public function prices($internalUse = FALSE)
 {
     $this->CashAndCarry = new CashAndCarry();
     if (!empty($this->request->data['zip'])) {
         $zipCode = $this->request->data['zip'];
     } else {
         $zipCode = null;
     }
     if (!empty($this->data['sponsor_id'])) {
         $presenter = $this->Presenter->findById($this->data['sponsor_id']);
     }
     if (!empty($presenter)) {
         $promoterId = 0;
         $presenterId = $presenter['Presenter']['id'];
     } else {
         $promoterId = 0;
         $presenterId = 0;
     }
     if (empty($this->request->data['items'])) {
         $items = array();
     } else {
         $items = $this->ShoppingCartItem->pruneItems($this->request->data['items'], false, $this->request->data['productcredits']);
     }
     $this->Session->write('user_id', $this->request->data['user_id']);
     $userId = $this->Session->read("user_id");
     if (empty($this->request->data['productcredits'])) {
         $productcredits = null;
     } else {
         $productcredits = Money::fromPennies((int) $this->request->data['productcredits']);
         //check if product credits is greater than their balance
         $balance = $this->ProductCredit->balance(Configure::read("market_id"), $presenterId, $userId);
         if ($productcredits->isGreaterThan($balance)) {
             $productcredits = $balance;
         }
     }
     //used for removing the ycash exempt value from the amount ycash can be applied
     $discount_exclusion = Money::fromFloat(0);
     foreach ($items as &$item) {
         //items that are y-cash excluded
         if (in_array($item['sku'], ProductGlobal::yCashExcluded())) {
             App::import("Model", "Item");
             $this->Item = new Item();
             $limit_item = $this->Item->detailsBySku($item['sku'], $this->Session->read('Config.language'), true);
             $discount_exclusion->add(Money::fromFloat($limit_item['price'] * $item['qty']));
         }
         if (empty($item['coupons']) || empty($item['coupons'][0])) {
             continue;
         }
         $couponIds = $item['coupons'];
         unset($item['coupons']);
         $coupons = $this->User->CouponPresenterUser->availableCouponsById($presenterId, $userId, $couponIds);
         foreach ($coupons as $coupon) {
             $item['coupons'][$coupon['id']] = array("discount_percentage" => $coupon['discount_percentage'], "discount_flat" => $coupon['discount_flat'], "name" => $coupon['name']);
         }
     }
     $toUseCoupons = array();
     $user_coupons = $this->User->CouponPresenterUser->availableCouponsById($presenterId, $userId, $this->ShoppingCartItem->getCoupons());
     foreach ($user_coupons as $coupon) {
         $toUseCoupons[$coupon['id']] = $coupon;
     }
     //This is for determining if use the discounted prices for coupon
     $is_presenter = $this->Session->check('presenter_id');
     $result = $this->Order->getOrderCosts($zipCode, $items, $productcredits, $toUseCoupons, FALSE, $is_presenter, $userId);
     //y-cash excluded items
     $product_creditable = $result['total']['market_commissionable_total']->copy()->subtract($discount_exclusion);
     //check if discounts are larger than the adjusted discount limit
     if ($result['total']['productcredits'] > $product_creditable) {
         //adjust product credit amount
         $productcredits = $result['total']['product_creditable'];
         //get new order totals
         $result = $this->Order->getOrderCosts($zipCode, $items, $productcredits, $toUseCoupons, FALSE, $is_presenter, $userId);
     }
     // Add free catalog
     //        $items = $this->addFreeCatalog($result, $items);
     //        if ($result['total']['freeCatalog'] == true) {
     //            $result = $this->Order->getOrderCosts($zipCode, $items, $productcredits, $toUseCoupons, $is_presenter, $userId);
     //        }
     //add product creditable node
     $result['total']['product_creditable'] = $product_creditable;
     //last_quote_date
     $result['total']['last_quote_date'] = date('Y-m-d');
     //set order limits
     $market_id = $this->request->data['market_id'] ? $this->request->data['market_id'] : Configure::read("market_id");
     //market touch point
     $nfr_order_limit = $this->TraitCountry->getTrait($market_id, 'nfr_order_limit');
     if (!empty($nfr_order_limit)) {
         $order_limits = $this->_getOrderLimits($market_id);
         $result['total']['orderLimit'] = Money::fromFloat($order_limits['market_limit']);
         $result['total']['orderLimitUsed'] = $order_limits['used'];
         $result['total']['orderLimitRemaining'] = Money::fromFloat($order_limits['market_limit'])->subtract($order_limits['used']);
         $result['total']['orderLimitThrottleValue'] = $order_limits['period_value'];
         $result['total']['orderLimitThrottlePeriod'] = $order_limits['period'];
         $result['total']['rolling_used'] = $order_limits['rolling_used'];
         $result['total']['rollingRemaining'] = Money::fromFloat($order_limits['market_limit'])->subtract($order_limits['rolling_used']);
     }
     $result['total']['time'] = date("Y-m-d H:i:s");
     $this->Session->write('last_quote_date', date('Y-m-d'));
     if (!$internalUse) {
         $this->sendSuccess($result);
     } else {
//.........这里部分代码省略.........
开发者ID:kameshwariv,项目名称:testexample,代码行数:101,代码来源:CashandcarryController.php

示例6: checkPromoAdjustments

 /**
  * Check promo adjustments and return qty of promo items
  * @param $items
  * @param $credits
  * @param $qualifying_items
  * @return int
  */
 private function checkPromoAdjustments($items, $credits, $qualifying_items, $promo, $market_id)
 {
     $this->Item = new Item();
     $this->ItemAvailabilityTimes = new ItemAvailabilityTimes();
     $qualifying_items_value = Money::fromFloat(0);
     $non_qualifying_value = Money::fromFloat(0);
     $product_credits = Money::fromPennies($credits);
     $prices = [];
     $count = 0;
     $total_qualifying_items = 0;
     $hpi_qty = 0;
     $promo_iat = $this->ItemAvailabilityTimes->find('first', array('fields' => array('ItemAvailabilityTimes.item_availability_id'), 'joins' => array(array('table' => 'items', 'alias' => 'i', 'type' => 'INNER', 'foreignKey' => false, 'conditions' => array('ItemAvailabilityTimes.item_id = i.id', 'ItemAvailabilityTimes.start_date <=' => date("Y-m-d H:i:s"), 'OR' => array('ItemAvailabilityTimes.end_date >' => date("Y-m-d H:i:s"), 'ItemAvailabilityTimes.end_date' => NULL), 'i.sku' => $promo['reward_sku'])), array('table' => 'trait_countries', 'alias' => 'tc', 'type' => 'INNER', 'foreignKey' => false, 'conditions' => array('tc.name' => 'ns_warehouse', 'ItemAvailabilityTimes.ns_warehouse_id = tc.value', 'tc.reference_id' => $market_id)))));
     if (!empty($promo_iat['ItemAvailabilityTimes']['item_availability_id']) && in_array($promo_iat['ItemAvailabilityTimes']['item_availability_id'], [2, 3, 6, 8])) {
         // 2 = Sell remaining
         // 3 = Sell endless
         // 6 = Backorder Individual
         // 8 = Backorder All
         foreach ($items as $value) {
             // Database item
             $item_detail = $this->Item->detailsBySku($value['sku']);
             // Values
             $price = $item_detail['price'];
             $qty = (int) $value['qty'];
             $coupons = (int) count(array_unique($value['coupons']));
             $count += $qty;
             $hpi_qty += $coupons;
             $type = $item_detail['type'];
             if ($promo['reward_type'] == 1 || $promo['reward_type'] == 2) {
                 //BuyXgetY and hidden
                 $floor = $qty - $coupons;
                 if (in_array($value['sku'], $qualifying_items)) {
                     for ($i = 0; $i < $floor; $i++) {
                         $prices[] = $price;
                     }
                     $total_qualifying_items += $floor > 0 ? $floor : 0;
                     $qualifying_items_value->add(Money::fromFloat($price)->times($floor));
                 } else {
                     $non_qualifying_value->add(Money::fromFloat($price)->times($floor));
                 }
             } else {
                 if ($promo['reward_type'] == 3) {
                     //SpendXgetY
                     if (!in_array($type, array(Item::TYPE_SUPPLIES, Item::TYPE_SUPPLIES_SETS, Item::TYPE_PRESENTER_KIT))) {
                         $floor = (double) $qty - (double) $coupons / 2.0;
                         $non_qualifying_value->add(Money::fromFloat($price)->times($floor));
                     }
                 }
             }
         }
         if ($promo['reward_type'] == 1 || $promo['reward_type'] == 2) {
             //BuyXgetY and hidden
             // Sort by highest price
             rsort($prices);
             // Get yCash after other items
             if ($non_qualifying_value->isEqualOrGreaterThan($product_credits)) {
                 $after_cash = Money::fromFloat(0);
             } else {
                 $after_cash = $product_credits->copy()->subtract($non_qualifying_value);
             }
             if ($qualifying_items_value->amount > 0 && $after_cash->amount > 0) {
                 return $this->getHighestQty($prices, $after_cash->amount);
             } else {
                 return $total_qualifying_items;
             }
         } else {
             if ($promo['reward_type'] == 3) {
                 //SpendXgetY
                 $cart_amount = $non_qualifying_value->amount - $credits;
                 $this->PromotionalSpendingAmount = new PromotionalSpendingAmount();
                 $spending_data = $this->PromotionalSpendingAmount->find('first', ['conditions' => ['promotional_product_id' => $promo['id'], 'market_id' => $market_id]]);
                 $spending_amount = $spending_data['PromotionalSpendingAmount']['spending_amount'];
                 if ($cart_amount >= $spending_amount) {
                     return $promo['qty'];
                 } else {
                     return 0;
                 }
             }
         }
     }
     //if the promos item_availability_time is not 2,3,6,8 then just return 0
     //also a default return 0
     return 0;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:90,代码来源:PromoItemsBehavior.php

示例7: checkPromoAdjustments

 /**
  * Check promo adjustments and return qty of promo items
  * @param $items
  * @param $credits
  * @param $qualifying_items
  * @return int
  */
 private function checkPromoAdjustments($items, $credits, $qualifying_items)
 {
     $this->Item = new Item();
     $qualifying_items_value = Money::fromFloat(0);
     $non_qualifying_value = Money::fromFloat(0);
     $product_credits = Money::fromPennies($credits);
     $prices = [];
     $count = 0;
     $total_qualifying_items = 0;
     $hpi_qty = 0;
     foreach ($items as $value) {
         // Database item
         $item_detail = $this->Item->detailsBySku($value['sku']);
         // Values
         $price = $item_detail['price'];
         $qty = (int) $value['qty'];
         $coupons = (int) count(array_unique($value['coupons']));
         $count += $qty;
         $floor = $qty - $coupons;
         $hpi_qty += $coupons;
         if (in_array($value['sku'], $qualifying_items)) {
             for ($i = 0; $i < $floor; $i++) {
                 $prices[] = $price;
             }
             $total_qualifying_items += $floor > 0 ? $floor : 0;
             $qualifying_items_value->add(Money::fromFloat($price)->times($floor));
         } else {
             $non_qualifying_value->add(Money::fromFloat($price)->times($floor));
         }
     }
     // Sort by highest price
     rsort($prices);
     // Get yCash after other items
     if ($non_qualifying_value->isEqualOrGreaterThan($product_credits)) {
         $after_cash = Money::fromFloat(0);
     } else {
         $after_cash = $product_credits->copy()->subtract($non_qualifying_value);
     }
     if ($qualifying_items_value->amount > 0 && $after_cash->amount > 0) {
         return $this->getHighestQty($prices, $after_cash->amount);
     } else {
         return $total_qualifying_items;
     }
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:51,代码来源:PromoAdjustmentBehavior.php

示例8: getOrderSubtotal

 private function getOrderSubtotal($cartItems, $calcommission = true, $productCredits, $locale = "en_US")
 {
     $itemModel = ClassRegistry::init('Item');
     $subtotals = array();
     $this->setOrderTools();
     if (is_null($productCredits)) {
         $this->orderObject->productCredits = Money::fromPennies(0);
     } else {
         $this->orderObject->productCredits = $productCredits;
     }
     $presenter_market_id = Configure::read("presenter_market_id");
     $market_id = Configure::read('market_id');
     $count = 0;
     foreach ($cartItems as $key => $cartItem) {
         $this->orderObject->discounts = array();
         $item = $itemModel->detailsBySku($cartItem['sku'], $locale, true);
         //1
         $price = Money::fromString($item['price']);
         $this->orderObject->price_net = Money::fromString($item['price_net']);
         //1
         $this->orderObject->price_supplement = Money::fromString($item['price_supplement']);
         $this->orderObject->points = (double) $item['points'];
         $this->orderObject->totalPoints = (double) $item['points'] * $cartItem['qty'];
         $this->orderObject->originalSubtotal = $price->copy()->times($cartItem['qty']);
         $this->orderObject->itemSubtotal = $this->orderObject->originalSubtotal->copy();
         $this->orderObject->base_price->add($this->orderObject->price_net);
         $price_net = Money::fromString($item['price_net']);
         $price_supplement = Money::fromString($item['price_supplement']);
         if (!isset($cartItem['hiddenItem'])) {
             $this->orderObject->itemCount += $cartItem['qty'];
         }
         if (!isset($cartItem['hiddenItem'])) {
             $this->orderObject->totalItemCount += (int) $cartItem['qty'];
         }
         list($included, $childItemBackorder, $backorder) = $this->backOrderCheck($item, $cartItem);
         $this->orderObject->backOrderCount += $backorder;
         $hazmat = $this->hazMatCheck($item, $cartItem);
         $kudosItem = $cartItem['kudosItem'];
         $hiddenItem = $cartItem['hiddenItem'];
         $this->orderObject->vattotal += $item['price_supplement'] * $cartItem['qty'];
         $subtotals[$key] = array("id" => $item['id'], "image" => $item['image'], "sku" => $item['sku'], "type" => $item['type'], "item_type_id" => $item['item_type_id'], "qty" => $cartItem['qty'], "backordered" => $item['item_availability']['item_availability_id'] == 6 || $item['item_availability']['item_availability_id'] == 8, "childBackordered" => $childItemBackorder, "type_id" => $item['item_type_id'], "hazmat" => $hazmat, "price" => $price, "price_net" => $price_net, "price_supplement" => $price_supplement, "coupons" => $cartItem['coupons'], "item_availability" => $item['item_availability'], "backorder_message" => $item['backorder_message'], "backorder_title" => $item['backorder_title'], "taxable" => $item['taxable'], "kudosItem" => $kudosItem ? TRUE : FALSE, "hiddenItem" => $hiddenItem ? TRUE : FALSE, "name" => $item['name'], "included" => $included, "weight" => !empty($item['weight']) ? $item['weight'] * $cartItem['qty'] : 0.35 * $cartItem['qty'], "options" => empty($cartItem['options']) ? array() : $cartItem['options'], "tax_type" => $itemModel->getTaxTypeName($item['id']));
         //if($calccommission) {
         $commission = $this->getCommissions($item, $cartItem, $presenter_market_id, $market_id);
         $subtotals[$key]['commissionSubtotal'] = $this->orderObject->commissionSubtotal;
         $subtotals[$key]['originalSubtotal'] = $this->orderObject->originalSubtotal;
         //}
         $discountResult = $this->discounts($subtotals[$key], $cartItem, $commission, $presenter_market_id, $market_id);
         $subtotals[$key]['subtotal'] = $this->orderObject->itemSubtotal;
         $subtotals[$key]['originalSubtotal'] = $this->orderObject->originalSubtotal;
         $subtotals[$key]['discount'] = $this->orderObject->discount;
         $subtotals[$key]['discounts'] = $this->orderObject->discounts;
         $subtotals[$key]['commission'] = $discountResult['commission'];
         $subtotals[$key]['hpDisabled'] = $discountResult['hpDisabled'];
         $subtotals[$key]['points'] = $this->orderObject->totalPoints;
         $this->orderObject->totalSubtotal->add($this->orderObject->itemSubtotal);
         $count++;
     }
     //foreach($subtotals as $s){
     //	Debugger::log($s['price']);
     //}
     //Debugger::log($subtotals);
     return $subtotals;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:63,代码来源:Order.php

示例9: isGreaterThanZero

 public function isGreaterThanZero()
 {
     return $this->isGreaterThan(Money::fromPennies(0));
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:4,代码来源:Money.php

示例10: purchase


//.........这里部分代码省略.........
                 break;
         }
         if (!empty($this->request->data['cardExpMonth'])) {
             $this->request->data['cardExp'] = $this->request->data['cardExpMonth'] . "/" . $this->request->data['cardExpYear'];
         }
         if (!empty($validation_errors)) {
             $this->sendError(500, $validation_errors);
             return;
         }
     }
     if (empty($presenterId)) {
         $this->sendError(500, array("process_error" => array(DruniqueAPIUtil::content('presenter for purchase', $this->DruniqueAPI->page_data))));
         return;
     }
     /**
      * Return error when cart is empty
      */
     if (empty($this->request->data['items'])) {
         $this->sendError(500, ['process_error' => [DruniqueAPIUtil::content('no items in cart', $this->DruniqueAPI->page_data)]]);
         return;
     }
     $itemIds = $this->request->data['items'];
     $party = $this->Party->partyFromId($this->data['party_id'], $presenterId, true);
     if (!empty($party)) {
         $partyId = $party['Party']['id'];
     } else {
         $partyId = 0;
     }
     /**
      * @var Money
      */
     $productCredits = null;
     if (!empty($this->request->data['productcredits'])) {
         $productCredits = Money::fromPennies((int) $this->request->data['productcredits']);
     }
     $commission_total = null;
     //determine if user is a presenter
     $is_presenter = $this->Presenter->presenterFromUserId($userId);
     if (!empty($is_presenter)) {
         $commission_total = $this->request->data['commissionable_total'];
     }
     $country = $this->Country->getByMarketId(Configure::read("market_id"));
     if (!empty($this->request->data['state'])) {
         $state_id = (int) $this->Address->State->search($this->request->data['state']);
     } else {
         $state_id = null;
     }
     $first_last = array();
     if (empty($this->request->data['first_name'])) {
         $first_last['first_name'][0] = array(DruniqueAPIUtil::content('valid First Name', $this->DruniqueAPI->page_data));
     }
     if (Configure::read("market_id") != Market::MARKET_MEXICO) {
         if (empty($this->request->data['last_name'])) {
             $first_last['last_name'][0] = array(DruniqueAPIUtil::content('valid Last Name', $this->DruniqueAPI->page_data));
         }
     }
     @($address = array("first_name" => $this->request->data['first_name'], "last_name" => $this->request->data['last_name'], "address1" => $this->request->data['address1'], "address2" => $this->request->data['address2'], "address3" => $this->request->data['address3'], "city" => $this->request->data['city'], "state_id" => $state_id, "state" => $this->request->data['state'], "country_id" => $country['Country']['id'], "postal_code" => strtoupper($this->request->data['postal_code']), "phone" => $this->request->data['phone']));
     $email = ['email' => trim($this->request->data['email'])];
     $hasDailySpecial = false;
     $hasConventionTicket = false;
     $this->Address->set($address);
     $this->Email->set($email);
     /**
      * Currently us market does not require phone number
      */
     if (Configure::read("market_id") != Market::MARKET_USA) {
开发者ID:kameshwariv,项目名称:testexample,代码行数:67,代码来源:ShoppingcartController.php


注:本文中的Money::fromPennies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。