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


PHP Money::fromFloat方法代碼示例

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


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

示例1: testAddNoUser

 public function testAddNoUser()
 {
     $this->assertEqual($this->ShoppingCart->addItem("US-1001-00", array("qty" => 1)), array("success" => true, "count" => 1));
     $this->assertEqual($this->ShoppingCart->addItem("US-1012-00", array("qty" => 5, "US-1011-00" => array("skus" => array("US-1011-03" => 1, "US-1011-04" => 1, "US-1011-05" => 1, "US-1011-06" => 1)))), array("success" => true, "count" => 2));
     $this->assertEqual($this->ShoppingCart->getCart(), array("total" => array("subtotal" => Money::fromFloat(274), "taxes" => Money::fromFloat(0), "shipping" => Money::fromFloat(0), "total" => Money::fromFloat(274), "commissionable_total" => Money::fromFloat(274), 'productcredits' => Money::fromFloat(0), 'charge' => Money::fromFloat(274), 'usedCoupons' => array(), 'totalItemCount' => 6, 'toFreeShipping' => Money::fromFloat(-174)), "0" => array("item_id" => '1', 'sku' => 'US-1001-00', "name" => "Presenter Starter Kit", "quantity" => 1, "price" => Money::fromFloat(99.0), "subtotal" => Money::fromFloat(99.0), "taxes" => Money::fromFloat(0), "originalsubtotal" => Money::fromFloat(99.0), "discount" => Money::fromFloat(0), "discounts" => array(), "shipping" => Money::fromFloat(10), "total" => Money::fromFloat(99.0), 'image' => array('name' => 'Main', 'thumb_path' => '/img/product_images/fake_thumb.jpg', 'file_path' => '/img/product_images/fake_main.jpg'), "included" => array(), 'options' => array()), "1" => array("item_id" => '3', 'sku' => 'US-1012-00', "name" => "Minerals Pigment Set", "quantity" => 5, "price" => Money::fromFloat(35.0), "subtotal" => Money::fromFloat(175), "taxes" => Money::fromFloat(0), "shipping" => Money::fromFloat(5.0), "total" => Money::fromFloat(175), "originalsubtotal" => Money::fromFloat(175), "discount" => Money::fromFloat(0), "discounts" => array(), 'image' => array('name' => 'Main', 'thumb_path' => '/img/product_images/US-1011-00-thumb.png', 'file_path' => '/img/product_images/US-1011-00.jpg'), 'included' => array(array('name' => 'Sassy', 'shortname' => 'Sassy', 'id' => '7', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-03', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-03-thumb.jpg', 'file_path' => '/img/product_images/US-1011-03.jpg')), array('name' => 'Regal', 'shortname' => 'Regal', 'id' => '8', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-04', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-04-thumb.jpg', 'file_path' => '/img/product_images/US-1011-04.jpg')), array('name' => 'Flirty', 'shortname' => 'Flirty', 'id' => '9', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-05', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-05-thumb.jpg', 'file_path' => '/img/product_images/US-1011-05.jpg')), array('name' => 'Playful', 'shortname' => 'Playful', 'id' => '10', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-06', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-06-thumb.jpg', 'file_path' => '/img/product_images/US-1011-06.jpg'))), 'options' => array('US-1011-00' => array('skus' => array('US-1011-03' => 1, 'US-1011-04' => 1, 'US-1011-05' => 1, 'US-1011-06' => 1))))));
     $this->assertEqual($this->ShoppingCart->getCart("84003"), array("total" => array("subtotal" => Money::fromFloat(274), "taxes" => Money::fromFloat(18.5), "shipping" => Money::fromFloat(0), "total" => Money::fromFloat(292.5), "commissionable_total" => Money::fromFloat(274), 'productcredits' => Money::fromFloat(0), 'charge' => Money::fromFloat(292.5), 'usedCoupons' => array(), 'totalItemCount' => 6, 'toFreeShipping' => Money::fromFloat(-174)), "0" => array("item_id" => 1, 'sku' => 'US-1001-00', "name" => "Presenter Starter Kit", "quantity" => 1, "price" => Money::fromFloat(99.0), "subtotal" => Money::fromFloat(99.0), "taxes" => Money::fromFloat(6.68), "shipping" => Money::fromFloat(10), "originalsubtotal" => Money::fromFloat(99.0), "discount" => Money::fromFloat(0), "discounts" => array(), "total" => Money::fromFloat(105.68), 'image' => array('name' => 'Main', 'thumb_path' => '/img/product_images/fake_thumb.jpg', 'file_path' => '/img/product_images/fake_main.jpg'), "included" => array(), 'options' => array()), "1" => array("item_id" => 3, 'sku' => 'US-1012-00', "name" => "Minerals Pigment Set", "quantity" => 5, "price" => Money::fromFloat(35.0), "subtotal" => Money::fromFloat(175), "taxes" => Money::fromFloat(11.81), "shipping" => Money::fromFloat(5.0), "total" => Money::fromFloat(186.81), "originalsubtotal" => Money::fromFloat(175), "discount" => Money::fromFloat(0), "discounts" => array(), 'image' => array('name' => 'Main', 'thumb_path' => '/img/product_images/US-1011-00-thumb.png', 'file_path' => '/img/product_images/US-1011-00.jpg'), "included" => array(array('name' => 'Sassy', 'shortname' => 'Sassy', 'id' => '7', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-03', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-03-thumb.jpg', 'file_path' => '/img/product_images/US-1011-03.jpg')), array('name' => 'Regal', 'shortname' => 'Regal', 'id' => '8', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-04', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-04-thumb.jpg', 'file_path' => '/img/product_images/US-1011-04.jpg')), array('name' => 'Flirty', 'shortname' => 'Flirty', 'id' => '9', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-05', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-05-thumb.jpg', 'file_path' => '/img/product_images/US-1011-05.jpg')), array('name' => 'Playful', 'shortname' => 'Playful', 'id' => '10', 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => null, 'qty_purchased' => (int) 1, 'sku' => 'US-1011-06', 'image' => array('name' => 'main', 'thumb_path' => '/img/product_images/US-1011-06-thumb.jpg', 'file_path' => '/img/product_images/US-1011-06.jpg'))), 'options' => array('US-1011-00' => array('skus' => array('US-1011-03' => 1, 'US-1011-04' => 1, 'US-1011-05' => 1, 'US-1011-06' => 1))))));
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:7,代碼來源:ShoppingCartTest.php

示例2: orderCreate

 public function orderCreate($country_id, $presenterId, $userId, $hostmarket_id, $partyId)
 {
     $address = array("first_name" => "testing", "last_name" => "last", "address1" => "Some address 1", "address2" => "Some address 2", "address3" => "Some address 3", "city" => "Awesome city", "state_id" => 20, "postal_code" => "84003", "email_address" => "dev@youniqueproducts.com", "country_id" => $country_id);
     $promoterId = 2;
     //$presenterId = 141683; // from presenter , we get market_id for orders
     $items = array(array("sku" => "US-2005-00", "qty" => 1, options => array("US-1092-00" => array("skus" => array("US-1082-01" => 1, "US-1083-03" => 1)))));
     $coupons = array();
     $productCredits = Money::fromFloat(0.0);
     //20.00//29.00//29.00//45.00//29.00//90.00//75.00//175.00//58.00
     //$prices = $this->Order->getOrderCosts($address['postal_code'], $items,null, $coupons);
     $prices = $this->Order->getOrderCosts($address['postal_code'], $items, $productCredits, $coupons);
     //$prices = $this->getOrderCosts($address['country_id'], $items,null, $coupons);
     //echo "<pre>";
     //print_r($prices);exit;
     $insert_order = TRUE;
     //    $result = $this->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,null, $coupons,FALSE,$insert_order);
     $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address, Order::TYPE_PRODUCT, $productCredits, $coupons, FALSE);
     //    $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,$productCredits, $coupons,FALSE);//$insert_order
     $orderId = $this->Order->id;
     debug($orderId);
     //  debug($result);
     //   exit;
     $orderPaymentResult = array("success" => false, "payments" => array(array('type' => 'creditcard', 'amount' => $prices['total']['total'], "transaction_id" => "Wohootest", "identifier" => "3123", 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'failed')));
     $result = $this->Order->finalize($orderPaymentResult);
     debug($prices['total']['total']);
     $orderPaymentResult = array("success" => true, "payments" => array(array('type' => 'creditcard', 'transaction_id' => 'Wohootest', 'amount' => $prices['total']['total'], 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'success', "identifier" => "3123")));
     $result = $this->Order->finalize($orderPaymentResult);
     return $orderId;
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:29,代碼來源:PartyOrderSetTest.php

示例3: testProcessOrderLedgerPayments

 public function testProcessOrderLedgerPayments()
 {
     PHPUnit_Framework_Error_Warning::$enabled = FALSE;
     $result = $this->Payment->processOrderPayments("Test Order #13123", array(array("type" => "ledger", "presenter_id" => 1, "user_id" => 1, "amount" => Money::fromFloat(60)), array("type" => "creditcard", "amount" => Money::fromFloat(30), "cardholder" => "Test wohoo", "billingzip" => "84003", "cardnum" => "4068758923310472", "carexp" => "12/2015", "cardcode" => "962")));
     $this->assertTrue($result['success']);
     $this->assertTrue(!empty($result['payments'][0]['transaction_id']) && strlen($result['payments'][0]['transaction_id']) == 17);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:7,代碼來源:PaymentComponentTest.php

示例4: testProductCreditSubtractions

 public function testProductCreditSubtractions()
 {
     $presenterId = 1;
     $userId = 1;
     $this->assertEqual($this->ProductCredit->balance($presenterId, $userId), Money::fromFloat(70));
     $transactionId = $this->ProductCredit->authorize(ProductCredit::METHOD_MANUAL, ProductCredit::TYPE_PURCHASE, $presenterId, $userId, Money::fromFloat(20), "Steve", "Manual Subtraction");
     $this->assertEqual($transactionId !== false, true);
     $productCredit = $this->ProductCredit->findById($transactionId);
     unset($productCredit['ProductCredit']['id']);
     unset($productCredit['ProductCredit']['modified']);
     unset($productCredit['ProductCredit']['created']);
     $this->assertArraysEqual($productCredit, array('ProductCredit' => array('user_id' => '1', 'presenter_id' => '1', 'product_credit_type_id' => '4', 'product_credit_entry_type_id' => '2', 'product_credit_status_type_id' => '1', 'entry_user' => 'Steve', 'reference_id' => 'Manual Subtraction', 'amount' => '-20.00')));
     //Doesn't have enough money
     $this->assertEqual($this->ProductCredit->balance($presenterId, $userId), Money::fromFloat(50));
     $result = $this->ProductCredit->authorize(ProductCredit::METHOD_MANUAL, ProductCredit::TYPE_PURCHASE, $presenterId, $userId, Money::fromFloat(90), "Steve", "Manual Subtraction");
     $this->assertEqual($result, false);
     $this->assertEqual($this->ProductCredit->balance($presenterId, $userId), Money::fromFloat(50));
     //Doesn't have enough money, but somehow hacked around it
     // now you can set your expectations here
     $this->ProductCreditBadBalance->expects($this->at(0))->method('balance')->will($this->returnValue(Money::fromFloat(30000)));
     $this->ProductCreditBadBalance->expects($this->at(1))->method('balance')->will($this->returnValue(Money::fromFloat(-200)));
     $result = $this->ProductCreditBadBalance->authorize(ProductCredit::METHOD_MANUAL, ProductCredit::TYPE_PURCHASE, $presenterId, $userId, Money::fromFloat(90), "Steve", "Manual Subtraction");
     $this->assertEqual($result, false);
     $this->assertEqual($this->ProductCredit->balance($presenterId, $userId), Money::fromFloat(50));
     $productCredit = $this->ProductCredit->find("first", array("order" => "id desc"));
     unset($productCredit['ProductCredit']['id']);
     unset($productCredit['ProductCredit']['modified']);
     unset($productCredit['ProductCredit']['created']);
     $this->assertArraysEqual($productCredit, array('ProductCredit' => array('user_id' => '1', 'presenter_id' => '1', 'product_credit_type_id' => '4', 'product_credit_entry_type_id' => '2', 'product_credit_status_type_id' => '3', 'entry_user' => 'Steve', 'reference_id' => 'Manual Subtraction', 'amount' => '-90.00')));
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:30,代碼來源:ProductCreditTest.php

示例5: testRewardCalculation

 public function testRewardCalculation()
 {
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(45));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(45), "Free Product" => "0%", "Free Product Credits" => Money::fromFloat(0), "Half-Price Items" => 0));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(200.21));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(200.21), "Free Product" => "10%", "Free Product Credits" => Money::fromFloat(20.02), "Half-Price Items" => 1));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(349.99));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(349.99), "Free Product" => "10%", "Free Product Credits" => Money::fromFloat(35.0), "Half-Price Items" => 1));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(350.0));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(350.0), "Free Product" => "12%", "Free Product Credits" => Money::fromFloat(42.0), "Half-Price Items" => 2));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(350.01));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(350.01), "Free Product" => "12%", "Free Product Credits" => Money::fromFloat(42.0), "Half-Price Items" => 2));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(999.99));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(999.99), "Free Product" => "14%", "Free Product Credits" => Money::fromFloat(140.0), "Half-Price Items" => 3));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(1000.0));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(1000.0), "Free Product" => "16%", "Free Product Credits" => Money::fromFloat(160), "Half-Price Items" => 4));
     $rewards = $this->PartyReward->calculateRewards(Money::fromFloat(8000.0));
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(8000.0), "Free Product" => "16%", "Free Product Credits" => Money::fromFloat(1280), "Half-Price Items" => 4));
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:19,代碼來源:PartyRewardTest.php

示例6: calculateRewards

 public function calculateRewards(Money $amount, $points, $hostess_market_id)
 {
     $reward = $this->find("first", array("conditions" => array("points_min <=" => $points), "order" => "points_min desc"));
     // 		$excess = $amount->toFloat() - (float)$reward['PartyReward']['price_min'];
     // 		$range = (float)$reward['PartyReward']['price_max'] - (float)$reward['PartyReward']['price_min'];
     $excess = $points - (int) $reward['PartyReward']['points_min'];
     $range = (int) $reward['PartyReward']['points_max'] - (double) $reward['PartyReward']['points_min'];
     if ($range <= 0) {
         $ratio = "0";
     } else {
         $ratio = round($excess / $range, 2) + (int) $reward['PartyReward']['half_price_coupons'];
     }
     $product_credit_percentage = (int) $reward['PartyReward']['product_credit_percentage'] / 100;
     $rewards = $this->calculateRewardPoints($points, $hostess_market_id, $product_credit_percentage);
     //Kudos Start
     //$kudosData = $this->Kudos->checkPartyPoints($points);
     //Kudos End
     return array("Order Total" => $amount, "Points Total" => $rewards['Party Points'], "Points Needed" => (int) $reward['PartyReward']['points_max'] - $points + 1, "Progress Ratio" => $ratio, "Reward Points" => $rewards['Reward Points'], "Reward Peg Rates" => $this->rewardPegRates, "Free Product" => $reward['PartyReward']['product_credit_percentage'] . "%", "Free Product Credits" => $rewards['Free Product Credits'], "Half-Price Items" => $reward['PartyReward']['half_price_coupons'], "free_product_credits" => Money::fromFloat($rewards['Free Product Credits']), "half_price_item" => $reward['PartyReward']['half_price_coupons']);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:19,代碼來源:PartyReward.php

示例7: testprices

 public function testprices()
 {
     $result = $this->testAction('/Shoppingcart/prices', array('return' => 'vars'));
     //      debug($result);
     unset($result['result']['total']['time']);
     $expected = array('code' => (int) 200, 'error' => false, 'result' => array('total' => array('subtotal' => Money::fromFloat(0.0), 'discounts' => array(), 'taxes' => Money::fromFloat(0.0), 'shipping' => Money::fromFloat(10.0), 'total' => Money::fromFloat(10.0), 'kudos_total' => Money::fromFloat(0.0), 'productcredits' => Money::fromFloat(0.0), 'commissionable' => Money::fromFloat(0.0), 'commissionable_total' => Money::fromFloat(0.0), 'charge' => Money::fromFloat(10.0), 'usedCoupons' => array(), 'points' => (int) 0, 'market_commissionable_total' => Money::fromFloat(0.0), 'market_commissionable' => Money::fromFloat(0.0), 'presenter_commissionable' => Money::fromFloat(0.0), 'appliedPoints' => (int) 0, 'negativePoints' => (int) 0, 'totalItemCount' => (int) 0, 'toFreeShipping' => Money::fromFloat(200.0), 'prop65_flag' => false, 'errors_type' => 'none', 'errors' => 'none', 'product_creditable' => Money::fromFloat(0.0), 'last_quote_date' => '2015-03-26', 'orderLimit' => Money::fromFloat(800.0), 'orderLimitUsed' => Money::fromFloat(0.0), 'orderLimitRemaining' => Money::fromFloat(800.0), 'orderLimitThrottleValue' => '36', 'orderLimitThrottlePeriod' => 'daily', 'rolling_used' => Money::fromFloat(0.0), 'rollingRemaining' => Money::fromFloat(800.0))));
     /*   $expected = array(
     	'code' => (int) 200,
     	'error' => false,
     	'result' => array(
     		'total' => array(
     			'subtotal' => Money::fromFloat(0.00),
     			'discounts' => array(),
     			'taxes' => Money::fromFloat(0.00),
     			'shipping' => Money::fromFloat(5.50),
     			'total' =>Money::fromFloat(5.50),
     			'productcredits' => Money::fromFloat(0.00),
     			'commissionable' =>Money::fromFloat(0.00),
     			'commissionable_total' => Money::fromFloat(0.00),
     			'charge' => Money::fromFloat(5.50),
     			'usedCoupons' => array(),
     			'points' => (int) 0,
     			'market_commissionable_total' => Money::fromFloat(0.00),
     			'market_commissionable' => Money::fromFloat(0.00),
     			'presenter_commissionable' => Money::fromFloat(0.00),
     			'appliedPoints' => (int) 0,
     			'negativePoints' => (int) 0,
     			'totalItemCount' => (int) 0,
     			'toFreeShipping' => Money::fromFloat(100.00),
     			'prop65_flag' => false,
     			'errors_type' => 'none',
     			'errors' => 'none',
     			'product_creditable' => Money::fromFloat(0.00),
     			'last_quote_date' => '2015-03-13',
     			'time' => date('Y-m-d H:i:s')
                 )
     	)
     );
           */
     $this->assertEquals($result, $expected);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:41,代碼來源:ShoppingCartControllerTest.php

示例8: testDonationWithHalfOrder

 public function testDonationWithHalfOrder()
 {
     $nonce = Braintree_Test_Nonces::$transactable;
     $data = array('sponsor_id' => 984, "user_id" => "5824", 'sponsorSearch' => '', 'market_id' => 1, 'first_name' => 'prachita', 'last_name' => '00test', 'email' => 'venubabu@1800agile.com', 'address1' => '1825 W Research Way', 'address2' => '', 'address3' => '', 'city' => 'SALT LAKE CITY', 'county' => '', 'state' => 'Indiana', 'postal_code' => '84006', 'qas_state' => 'Indiana', 'qas_country' => 1, 'sameAsShipping' => 'on', 'billing_market_id' => '1', 'billingEmail' => '', 'billingAddress1' => '', 'billingAddress2' => '', 'billingCity' => '', 'billingState' => '', 'billingZip' => '', 'billingCardholderFirstName' => 'test', 'billingCardholderLastName' => 'test1', 'cardNum' => '4111111111111111', 'cardCode' => '115', 'cardExpMonth' => '07', 'cardExpYear' => '2019', 'items' => array(array("sku" => "US-11901-01", "qty" => 1, "coupons" => array("1" => array("discount_percentage" => 50, "discount_flat" => Money::fromFloat(0), "name" => "Half Priced Item")))), "party_id" => "Select the party", "productcredits" => 0, "commissionable_total" => 39.0, "processor" => 2, "hasdonation" => true);
     $data1 = array("sku" => "US-11901-01", "qty" => 1);
     //[coupons][]:832447
     $clear1 = $this->testAction('/shoppingcart/clear', array('return' => 'vars'));
     $data2 = array("sku" => "US-1017-00", "qty" => 1);
     $adding = $this->testAction('shoppingcart/add', array('data' => $data1, 'method' => 'post', 'return' => 'vars'));
     //  $adding = $this->testAction('shoppingcart/add',array('data' => $data2, 'method' => 'post','return' => 'vars'));
     $actual1 = $this->testAction('/shoppingcart/purchase', array('data' => $data, 'method' => 'post', 'return' => 'vars'));
     $orderId = $actual1['result']['id'];
     $actualdata = $this->Order->find('first', array('conditions' => array('id' => $orderId)));
     //  debug($actualdata);
     //  debug($actual1);
     unset($actualdata['Order']['date_started']);
     unset($actualdata['Order']['date_completed']);
     unset($actualdata['Order']['_auditdate']);
     $expected1 = array('Order' => array('id' => $orderId, 'user_id' => '5824', 'presenter_id' => '984', 'promoter_id' => '0', 'party_id' => '0', 'order_type_id' => '3', 'order_status_id' => '3', 'secondary_order_status_id' => null, 'market_id' => '1', 'order_market_id' => '1', 'subtotal' => '19.50', 'taxtotal' => '0.00', 'shippingtotal' => '5.50', 'discount' => '0.00', 'commissionable_total' => '0.00', 'market_commissionable' => '0.00', 'presenter_commissionable' => '0.00', 'grand_total' => '25.00', 'point_total' => '0.00', 'donation' => '0.00', 'ip_address' => '2130706433', 'itemCount' => '1'));
     $this->assertEqual($actualdata, $expected1);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:21,代碼來源:FoundationDonationTest.php

示例9: testycash

 public function testycash()
 {
     /*
     	$yCashCreated = $this->ProductCredit->saveCreate(array(
                         "presenter_id" =>  203778,
                         "market_id"=>1,
                         "product_credit_type_id"=>4,
                         "coupon_id"=>1,
                         "discount_percentage"=>50,
                         //"user_id" => 2,
                         "reference_id" => 2,
                         "user_visible" => 0,
                         "start_date"=>date('Y/m/d H:i:s'),
                         "end_date" => "0000-00-00"
     							));
                    // $yCashCreated = $this->_refundYCash($value['transactionid']);
     	
     	}
     */
     $yCashCreated = $this->ProductCredit->saveCreate(array("market_id" => 2, "user_id" => 2082448, "presenter_id" => 203775, "product_credit_type_id" => 4, "product_credit_entry_type_id" => 2, "product_credit_status_type_id" => 1, "amount" => Money::fromFloat(200.0), "reference_id" => "test"));
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:21,代碼來源:YcashTest_1.php

示例10: main

 public function main()
 {
     if (empty($this->args[0])) {
         $today = strtotime(date("Y-m-d 00:00:00"));
     } else {
         $today = strtotime(date("Y-m-d 00:00:00", strtotime($this->args[0])));
     }
     /***
      * BIRTHDAY CASH
      */
     $result = $this->Presenter->find("all", array("contain" => array("User" => array("fields" => array("id", "date_of_birth"))), "conditions" => array("month(User.date_of_birth) = " . date("m", $today), "day(User.date_of_birth) = " . date("d", $today), "Presenter.presenter_status_id" => PresenterStatus::COMPLETE)));
     foreach ($result as $presenter) {
         $birthday = date("Y-m-d", $today);
         if (!$this->Presenter->User->ProductCredit->checkExists(ProductCredit::TYPE_BIRTHDAY, $presenter['User']['id'], $birthday)) {
             // market touch point
             $trait = $this->TraitCountry->getTrait($presenter['Presenter']['market_id'], 'birthday_cash');
             $amount = !empty($trait) ? $trait : $this->TraitCountry->getTrait(1, 'birthday_cash');
             $this->Presenter->User->ProductCredit->credit(ProductCredit::METHOD_SYSTEM, ProductCredit::TYPE_BIRTHDAY, $presenter['Presenter']['market_id'], $presenter['Presenter']['id'], $presenter['User']['id'], Money::fromFloat($amount), "BirthdayCashShell", $birthday);
         }
     }
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:21,代碼來源:BirthdayCashShell.php

示例11: testFinalizeParty

 public function testFinalizeParty()
 {
     $presenterId = 1;
     $userId = 3;
     $rewardAmount = Money::fromFloat(52.2);
     $this->Party->id = 3;
     $rewards = $this->Party->calculateRewards();
     $this->assertArraysEqual($rewards, array("Order Total" => Money::fromFloat(435), "Free Product" => "12%", "Progress Ratio" => 2.57, "Free Product Credits" => $rewardAmount, "Half-Price Items" => 2));
     $oldBalance = $this->Party->ProductCredit->balance($presenterId, $userId);
     $oldCoupons = $this->User->CouponPresenterUser->availableHalfOffCoupons($presenterId, $userId);
     $this->Party->finalize();
     $newBalance = $this->Party->ProductCredit->balance($presenterId, $userId);
     $newCoupons = $this->User->CouponPresenterUser->availableHalfOffCoupons($presenterId, $userId);
     $this->assertEqual($newBalance, $rewardAmount->copy()->add($oldBalance));
     $this->assertEqual(count($newCoupons), count($oldCoupons) + $rewards['Half-Price Items']);
     $this->Party->id = 1;
     $fields = $this->Party->read(array("presenter_id", "hostess_id"));
     $oldBalance = $this->Party->ProductCredit->balance($presenterId, $userId);
     $oldCoupons = $this->User->CouponPresenterUser->availableHalfOffCoupons($presenterId, $userId);
     $this->Party->finalize();
     $newBalance = $this->Party->ProductCredit->balance($presenterId, $userId);
     $this->assertEqual($newBalance, $oldBalance);
     $this->assertEqual(count($newCoupons), count($oldCoupons));
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:24,代碼來源:PartyTest.php

示例12: testCantoUkHalfpriceWithcashOrder

 public function testCantoUkHalfpriceWithcashOrder()
 {
     if (isset($_REQUEST["shipment_country_id"])) {
         $country_id = $_REQUEST["shipment_country_id"];
     } else {
         $country_id = 5;
     }
     $marketId = 5;
     $commission_rate = 0.25;
     //0.20;//0.25;
     $presenterMarketId = 2;
     if (isset($_REQUEST["pid"])) {
         $presenterId = $_REQUEST["pid"];
     } else {
         $presenterId = 202807;
         //203796;//203778;//201406;//203776;//203663;//203776;//203778;//203775;//203778;
     }
     //debug($presenterId."".$country_id);
     $userId = 193541;
     //1091475;//2082454;//1610480;//2003031;//1926829;//2003031;//2082454;//4;//2082448;//2082454;
     $partyId = 223;
     //213;
     $productCredits = Money::fromFloat(29.0);
     //29.00
     $address = array("first_name" => "testing", "last_name" => "last", "address1" => "Some address 1", "address2" => "Some address 2", "address3" => "Some address 3", "city" => "Awesome city", "state_id" => 20, "postal_code" => "84003", "email_address" => "dev@youniqueproducts.com", "country_id" => $country_id);
     $promoterId = 2;
     //$presenterId = 141683; // from presenter , we get market_id for orders
     $items = array(array("sku" => "US-1017-00", "qty" => 4, "coupons" => array("1" => array("discount_percentage" => 50, "discount_flat" => Money::fromFloat(0), "name" => "Half Priced Item"), "2" => array("discount_percentage" => 50, "discount_flat" => Money::fromFloat(0), "name" => "Half Priced Item"))));
     $coupons = array();
     $prices = $this->Order->getOrderCosts($address['postal_code'], $items, $productCredits, $coupons);
     //$prices = $this->getOrderCosts($address['country_id'], $items,null, $coupons);
     //echo "<pre>";
     //print_r($prices);exit;
     $insert_order = TRUE;
     //    $result = $this->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,null, $coupons,FALSE,$insert_order);
     $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address, Order::TYPE_PRODUCT, $productCredits, $coupons, FALSE);
     //    $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,$productCredits, $coupons,FALSE);//$insert_order
     $orderId = $this->Order->id;
     //     debug($orderId);
     //  debug($result);
     //   exit;
     $orderPaymentResult = array("success" => false, "payments" => array(array('type' => 'creditcard', 'amount' => $prices['total']['total'], "transaction_id" => "Wohootest", "identifier" => "3123", 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'failed')));
     $result = $this->Order->finalize($orderPaymentResult);
     //      debug($prices['total']['total']);
     $orderPaymentResult = array("success" => true, "payments" => array(array('type' => 'creditcard', 'transaction_id' => 'Wohootest', 'amount' => $prices['total']['total'], 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'success', "identifier" => "3123")));
     $result = $this->Order->finalize($orderPaymentResult);
     //  $presenterId = 154305;
     //   $userId  = 1477959;
     //   $orderId = 2000149;
     $marketcomission = $this->OrderCommission->calculateCommission($orderId, $marketId, $presenterMarketId);
     // $marketcomission=$marketCommissionable*(5/6);
     $RoyaltyAmount = $this->OrderCommission->getRoyaltiesEarnedByOrderId($orderId);
     $expected_value = round($marketcomission * $commission_rate, 2);
     //    $expected_value = '0.00';
     $this->assertEqual($RoyaltyAmount, $expected_value);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:56,代碼來源:OrderCreateCommissionTest.php

示例13: listRetailCommissions

 public function listRetailCommissions($status = self::STATUS_UNPAID, $limit = null, $threeHourWindow = true, $thread = NULL)
 {
     App::import('model', 'Market');
     $status = strtolower($status);
     $order = "date_earned asc";
     if ($status == "paid") {
         $conditions = array("RoyaltiesEarned.date_paid is not null");
     } else {
         if ($status == "failed") {
             $conditions = array("RoyaltiesEarned.date_paid is null", "RoyaltiesEarned.date_attempted is not null");
         } else {
             $conditions = array("RoyaltiesEarned.date_paid is null", "RoyaltiesEarned.date_attempted is null");
             if ($threeHourWindow === true) {
                 $conditions[] = "RoyaltiesEarned.date_earned < DATE_SUB('" . date("Y-m-d H:i:s") . "', INTERVAL 3 HOUR)";
             }
         }
     }
     $conditions["RoyaltiesEarned.royalty_type_id"] = self::TYPE_RETAIL;
     $conditions["RoyaltiesEarned.royalty_status_id"] = RoyaltiesEarned::STATUS_APPROVED;
     if ($thread !== NULL) {
         $conditions["SUBSTRING(RoyaltiesEarned.presenter_id, -1)"] = $thread;
     }
     $commissions = $this->find("all", array("contain" => array("Presenter" => array("User" => array("RoyaltiesEmail")), "Order"), "fields" => array("*", "(select sum(amount) from royalties_earned as re where re.presenter_id = RoyaltiesEarned.presenter_id) as totalRoyalties"), "conditions" => $conditions, "order" => $order, "limit" => $limit));
     $outCommissions = array();
     foreach ($commissions as $commission) {
         $cardLimit = Money::fromFloat($commission['RoyaltiesEarned']['market_id'] == Market::MARKET_MEXICO ? 750 : 50);
         //get currency
         $market_id = $commission['RoyaltiesEarned']['market_id'];
         $currency = $this->Market->getCurrencyType($market_id);
         if ((int) $market_id == Market::MARKET_MEXICO) {
             if (!$this->payMexicoCommissions($commission['Presenter']['id'])) {
                 $this->clear();
                 $this->id = $commission['RoyaltiesEarned']['id'];
                 $this->saveField("royalty_status_id", RoyaltiesEarned::STATUS_PRESENTER_NOT_VERIFIED);
                 continue;
             }
         } else {
             if ((int) $market_id == Market::MARKET_FRANCE) {
                 if (!$this->payFranceCommissions($commission['Presenter']['id'])) {
                     $this->clear();
                     $this->id = $commission['RoyaltiesEarned']['id'];
                     $this->saveField("royalty_status_id", RoyaltiesEarned::STATUS_PRESENTER_NOT_VERIFIED);
                     continue;
                 }
             }
         }
         $outCommissions[] = array("id" => $commission['RoyaltiesEarned']['id'], "presenter_sequence_id" => $commission['Presenter']['presenter_sequence_id'], "presenter_id" => $commission['Presenter']['id'], "name" => $commission['Presenter']['User']['first_name'] . " " . $commission['Presenter']['User']['last_name'], "first_name" => $commission['Presenter']['User']['first_name'], "payquickeremail" => $commission['Presenter']['User']['RoyaltiesEmail']['email'], "type" => $commission['RoyaltiesEarned']['royalty_type_id'] == RoyaltiesEarned::TYPE_RETAIL ? 'retail' : 'other', "amount" => $commission['RoyaltiesEarned']['amount'], "withholding" => $commission['RoyaltiesEarned']['withholding'], "market_id" => $commission['RoyaltiesEarned']['market_id'], "currency" => $currency, "order_percentage" => $commission['RoyaltiesEarned']['order_percentage'], "order_id" => $commission['RoyaltiesEarned']['order_id'], "order_commissionable" => $commission['Order']['commissionable_total'], "order_subtotal" => $commission['Order']['subtotal'], "date_earned" => $commission['RoyaltiesEarned']['date_earned'], "date_attempted" => $commission['RoyaltiesEarned']['date_attempted'], "total_royalties" => (string) Money::fromFloat($commission[0]['totalRoyalties']), "forceCard" => Money::fromFloat($commission[0]['totalRoyalties'])->isGreaterThan($cardLimit) ? 'true' : 'false');
     }
     return $outCommissions;
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:50,代碼來源:RoyaltiesEarned.php

示例14: testPencilSet15

 public function testPencilSet15()
 {
     $countryId = '1';
     $presenterId = '203720';
     $userId = '1101371';
     $hostMarketId = '1';
     $partyId = '213';
     $items = array(array("sku" => "US-32101-03", "qty" => 1));
     $amountadjust = '0.00';
     $resulto = $this->placeOrder($countryId, $presenterId, $userId, $hostMarketId, $partyId, $items, $amountadjust);
     $orderId = $resulto['orderId'];
     unset($resulto['orderId']);
     //    debug($resulto);
     $expected = array((int) 0 => array('item_id' => '354', 'image' => array('name' => 'Moodstruck Precision Pencil Set Box Set of 15', 'thumb_path' => '/en_US/img/product_images/US-32101-03-thumb.jpg', 'file_path' => '/en_US/img/product_images/US-32101-03.jpg'), 'sku' => 'US-32101-03', 'name' => 'Moodstruck Precision Pencil Set Box Set of 15', 'dailyspecial' => false, 'backordered' => false, 'childBackordered' => false, 'item_availability' => array('id' => '469', 'item_id' => '354', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'backorder_message' => 'Due to overwhelming popularity, our Moodstruck Precision Pencil Set Box Set of 15 is currently on back order.', 'backorder_title' => 'This set is temporarily on back order', 'type_id' => '3', 'quantity' => (int) 1, 'price' => Money::fromFloat(165.0), 'points' => (int) 1650, 'commission' => Money::fromFloat(165.0), 'subtotal' => Money::fromFloat(165.0), 'commissionSubtotal' => Money::fromFloat(165.0), 'originalsubtotal' => Money::fromFloat(165.0), 'taxes' => Money::fromFloat(0.0), 'shipping' => Money::fromFloat(5.5), 'discount' => Money::fromFloat(0.0), 'discounts' => array(), 'kudosItem' => false, 'total' => Money::fromFloat(165.0), 'included' => array((int) 0 => array('name' => 'Moodstruck Precision Pencils - for Lips - Perky', 'shortname' => 'Perky', 'id' => '330', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12101-01', 'item_availability' => array('id' => '445', 'item_id' => '330', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Perky', 'thumb_path' => '/en_US//img/product_images/US-12101-01-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12101-01.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Lips'), (int) 1 => array('name' => 'Moodstruck Precision Pencils - for Lips - Pompous', 'shortname' => 'Pompous', 'id' => '331', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12101-02', 'item_availability' => array('id' => '446', 'item_id' => '331', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Pompous', 'thumb_path' => '/en_US//img/product_images/US-12101-02-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12101-02.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Lips'), (int) 2 => array('name' => 'Moodstruck Precision Pencils - for Lips - Posh', 'shortname' => 'Posh', 'id' => '332', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12101-03', 'item_availability' => array('id' => '447', 'item_id' => '332', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Posh', 'thumb_path' => '/en_US//img/product_images/US-12101-03-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12101-03.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Lips'), (int) 3 => array('name' => 'Moodstruck Precision Pencils - for Lips - Pouty', 'shortname' => 'Pouty', 'id' => '333', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12101-04', 'item_availability' => array('id' => '448', 'item_id' => '333', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Pouty', 'thumb_path' => '/en_US//img/product_images/US-12101-04-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12101-04.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Lips'), (int) 4 => array('name' => 'Moodstruck Precision Pencils - for Lips - Primal', 'shortname' => 'Primal', 'id' => '334', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12101-05', 'item_availability' => array('id' => '449', 'item_id' => '334', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Primal', 'thumb_path' => '/en_US//img/product_images/US-12101-05-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12101-05.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Lips'), (int) 5 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Passionate', 'shortname' => 'Passionate', 'id' => '335', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-01', 'item_availability' => array('id' => '450', 'item_id' => '335', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Passionate', 'thumb_path' => '/en_US//img/product_images/US-12102-01-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-01.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 6 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Perfect', 'shortname' => 'Perfect', 'id' => '336', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-02', 'item_availability' => array('id' => '451', 'item_id' => '336', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Perfect', 'thumb_path' => '/en_US//img/product_images/US-12102-02-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-02.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 7 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Polished', 'shortname' => 'Polished', 'id' => '337', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-03', 'item_availability' => array('id' => '452', 'item_id' => '337', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Polished', 'thumb_path' => '/en_US//img/product_images/US-12102-03-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-03.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 8 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Precarious', 'shortname' => 'Precarious', 'id' => '338', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-04', 'item_availability' => array('id' => '453', 'item_id' => '338', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Precarious', 'thumb_path' => '/en_US//img/product_images/US-12102-04-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-04.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 9 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Precious', 'shortname' => 'Precious', 'id' => '339', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-05', 'item_availability' => array('id' => '454', 'item_id' => '339', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Precious', 'thumb_path' => '/en_US//img/product_images/US-12102-05-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-05.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 10 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Presumptuous', 'shortname' => 'Presumptuous', 'id' => '340', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-06', 'item_availability' => array('id' => '455', 'item_id' => '340', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Presumptuous', 'thumb_path' => '/en_US//img/product_images/US-12102-06-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-06.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 11 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Prim', 'shortname' => 'Prim', 'id' => '341', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-07', 'item_availability' => array('id' => '456', 'item_id' => '341', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Prim', 'thumb_path' => '/en_US//img/product_images/US-12102-07-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-07.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 12 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Pristine', 'shortname' => 'Pristine', 'id' => '342', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-08', 'item_availability' => array('id' => '457', 'item_id' => '342', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Pristine', 'thumb_path' => '/en_US//img/product_images/US-12102-08-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-08.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 13 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Proper', 'shortname' => 'Proper', 'id' => '343', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-09', 'item_availability' => array('id' => '458', 'item_id' => '343', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Proper', 'thumb_path' => '/en_US//img/product_images/US-12102-09-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-09.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 14 => array('name' => 'Moodstruck Precision Pencils - for Eyes - Prosperous', 'shortname' => 'Prosperous', 'id' => '344', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-12102-10', 'item_availability' => array('id' => '459', 'item_id' => '344', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Prosperous', 'thumb_path' => '/en_US//img/product_images/US-12102-10-thumb.jpg', 'file_path' => '/en_US//img/product_images/US-12102-10.jpg'), 'tag' => 'Moodstruck Precision Pencils - for Eyes'), (int) 15 => array('name' => 'Pencil Sharpener', 'shortname' => 'Precision Pencil Sharpener', 'id' => '356', 'orderable' => true, 'in_stock' => true, 'item_type_id' => '1', 'children_qty_required' => null, 'qty_required' => '1', 'sku' => 'US-53001-01', 'item_availability' => array('id' => '471', 'item_id' => '356', 'item_availability_id' => '3', 'start_date' => '2014-09-01 00:00:00', 'end_date' => null, 'estimated_date' => null), 'image' => array('name' => 'Precision Pencil Sharpener', 'thumb_path' => '/en_US/img/product_images/US-53001-01-thumb.jpg', 'file_path' => '/en_US/img/product_images/US-53001-01.jpg'), 'tag' => '')), 'options' => array(), 'prop65_flag' => '0'), 'total' => array('subtotal' => Money::fromFloat(165.0), 'discounts' => array(), 'taxes' => Money::fromFloat(0.0), 'shipping' => Money::fromFloat(0.0), 'total' => Money::fromFloat(165.0), 'productcredits' => Money::fromFloat(0.0), 'commissionable' => Money::fromFloat(165.0), 'commissionable_total' => Money::fromFloat(165.0), 'charge' => Money::fromFloat(165.0), 'usedCoupons' => array(), 'points' => (int) 1650, 'market_commissionable_total' => Money::fromFloat(165.0), 'market_commissionable' => Money::fromFloat(165.0), 'presenter_commissionable' => Money::fromFloat(165.0), 'appliedPoints' => (double) 1650, 'negativePoints' => (double) 0, 'totalItemCount' => (int) 1, 'toFreeShipping' => Money::fromFloat(-65.0), 'prop65_flag' => false, 'errors_type' => 'none', 'errors' => 'none'));
     //array();
     $this->assertEqual($resulto, $expected);
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:17,代碼來源:OrderSetTest.php

示例15: _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


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