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


PHP Checkout类代码示例

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


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

示例1: fromJson

 public static function fromJson($json)
 {
     $r = new Checkout();
     $r->setItems(array_map(function ($json) {
         return CheckoutItem::fromJson($json);
     }, $json->items));
     $r->setTotal(Price::fromJson($json->total));
     return $r;
 }
开发者ID:purchased-at,项目名称:sdk-php,代码行数:9,代码来源:Checkout.php

示例2: testBuildWithoutTotal

 public function testBuildWithoutTotal()
 {
     $checkout = new Checkout();
     $checkout->addItem(CheckoutItem::of(1, 'SKU')->setExternalId('external_id')->setName(['en' => 'Name'])->setPrice(['EUR' => '10.0']));
     try {
         $checkout->build();
         $this->fail();
     } catch (\LogicException $ignored) {
     }
 }
开发者ID:purchased-at,项目名称:sdk-php,代码行数:10,代码来源:CheckoutTest.php

示例3: setShippingMethod

 function setShippingMethod($data, $form)
 {
     $cart = $this->owner->Cart();
     $option = null;
     if (isset($data['ShippingMethodID'])) {
         $option = DataObject::get_by_id("ShippingMethod", (int) $data['ShippingMethodID']);
     }
     //assign option to order / modifier
     if ($option) {
         $checkout = new Checkout($cart);
         $checkout->setShippingMethod($option);
     }
     Director::redirect($this->NextStepLink('paymentmethod'));
 }
开发者ID:tylerkidd,项目名称:silverstripe-shop-shippingframework,代码行数:14,代码来源:CheckoutStep_ShippingMethod.php

示例4: testSave

 function testSave()
 {
     //Arrange
     $copy_id = 1;
     $patron_id = 1;
     $id = 1;
     $due_date = '2015-10-10';
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date, $id);
     $test_checkout->save();
     //Act
     $result = Checkout::getAll();
     //Assert
     $this->assertEquals($test_checkout, $result[0]);
 }
开发者ID:bborealis,项目名称:library-1,代码行数:14,代码来源:CheckoutTest.php

示例5: test_find

 function test_find()
 {
     //Arrange
     $due_date = "0001-01-01";
     $test_checkout = new Checkout($due_date);
     $test_checkout->save();
     $due_date2 = "2020-01-01";
     $test_checkout2 = new Checkout($due_date2);
     $test_checkout2->save();
     //Act
     $result = Checkout::find($test_checkout->getId());
     //Assert
     $this->assertEquals($test_checkout, $result);
 }
开发者ID:jlbethel,项目名称:Library,代码行数:14,代码来源:CheckoutTest.php

示例6: create

 /**
  * Create member account from data array.
  * Data must contain unique identifier.
  *
  * @throws ValidationException
  * @param $data - map of member data
  * @return Member|boolean - new member (not saved to db), or false if there is an error.
  */
 public function create($data)
 {
     $result = new ValidationResult();
     if (!Checkout::member_creation_enabled()) {
         $result->error(_t("Checkout.MEMBERSHIPSNOTALLOWED", "Creating new memberships is not allowed"));
         throw new ValidationException($result);
     }
     $idfield = Config::inst()->get('Member', 'unique_identifier_field');
     if (!isset($data[$idfield]) || empty($data[$idfield])) {
         $result->error(sprintf(_t("Checkout.IDFIELDNOTFOUND", "Required field not found: %s"), $idfield));
         throw new ValidationException($result);
     }
     if (!isset($data['Password']) || empty($data['Password'])) {
         $result->error(_t("Checkout.PASSWORDREQUIRED", "A password is required"));
         throw new ValidationException($result);
     }
     $idval = $data[$idfield];
     if (ShopMember::get_by_identifier($idval)) {
         $result->error(sprintf(_t("Checkout.MEMBEREXISTS", "A member already exists with the %s %s"), _t("Member." . $idfield, $idfield), $idval));
         throw new ValidationException($result);
     }
     $member = new Member(Convert::raw2sql($data));
     $validation = $member->validate();
     if (!$validation->valid()) {
         //TODO need to handle i18n here?
         $result->error($validation->message());
     }
     if (!$result->valid()) {
         throw new ValidationException($result);
     }
     return $member;
 }
开发者ID:renskorswagen,项目名称:silverstripe-shop,代码行数:40,代码来源:ShopMemberFactory.php

示例7: tearDown

 protected function tearDown()
 {
     Author::deleteAll();
     Book::deleteAll();
     Checkout::deleteAll();
     Patron::deleteAll();
 }
开发者ID:umamiMike,项目名称:library-1,代码行数:7,代码来源:BookTest.php

示例8: test_getCheckouts

 function test_getCheckouts()
 {
     //Arrange
     $name = "Jerald the crotchety grandpa";
     $test_patron = new Patron($name);
     $test_patron->save();
     $checked_in_status = 0;
     $due_date = "1234-12-12";
     $copy_id = 5;
     $new_checkout = new Checkout($checked_in_status, $due_date, $copy_id, $test_patron->getId());
     $new_checkout->save();
     //Act
     $result = $test_patron->getCheckouts();
     //Assert
     $this->assertEquals([$new_checkout], $result);
 }
开发者ID:kevintokheim,项目名称:Library,代码行数:16,代码来源:PatronTest.php

示例9: is_active

 public function is_active($country = 0)
 {
     global $temp_orders_id;
     $temp_data = Checkout::get_all_data_from_temp_db($temp_orders_id);
     foreach ($this->instances as $data) {
         if ($data['status'] == 'true') {
             if ($temp_orders_id > 0) {
                 if ($country > 0) {
                     if (parent::checkZone($data['zone'], $country)) {
                         return true;
                     }
                 } else {
                     if (parent::checkZone($data['zone'], $temp_data[$temp_orders_id]['orders']['delivery_country'])) {
                         return true;
                     }
                 }
             } else {
                 if ($country > 0) {
                     if (parent::checkZone($data['zone'], $country)) {
                         return true;
                     }
                 } else {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:CristianCCIT,项目名称:shop4office,代码行数:29,代码来源:Flat_module.php

示例10: run

    public function run()
    {
        parent::run();
        $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets', false, -1, true);
        $cs = Yii::app()->clientScript;
        $cs->registerCssFile($assets . '/css/wsaddtocartmodal.css');
        Yii::app()->clientScript->registerScript('instantiate checkout', sprintf('$(document).ready(function () {
					checkout = new Checkout(%s);
				});', Checkout::getCheckoutJSOptions()), CClientScript::POS_HEAD);
        // No item added to cart.
        if (empty($this->objCartItem)) {
            return;
        }
        $this->objCart = Yii::app()->shoppingcart;
        $this->intItemCount = Yii::app()->shoppingcart->totalItemCount;
        $this->strItems = $this->intItemCount > 1 ? Yii::t('cart', 'items') : Yii::t('cart', 'item');
        $arrItems = Yii::app()->shoppingcart->cartItems;
        if (count($arrItems)) {
            $this->intImageID = $this->objCartItem->Prod->image_id;
            $dataProvider = $this->objCartItem->Prod->related();
            $arrRel = $dataProvider->Data;
            $dataProvider = $this->objCartItem->Prod->autoadd();
            $arrAuto = $dataProvider->Data;
            $arr = array_merge($arrAuto, $arrRel);
            // right now we only want 3 related items at most
            while (count($arr) > $this->intCountRelated) {
                array_pop($arr);
            }
            $this->arrObjRelated = $arr;
        } else {
            $this->objCartItem = new CartItem();
            // empty object
        }
        $this->render('addtocartmodal');
    }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:35,代码来源:wsaddtocartmodal.php

示例11: getPasswordFields

 public function getPasswordFields()
 {
     $loginlink = "Security/login?BackURL=" . CheckoutPage::find_link(true);
     $fields = FieldList::create(HeaderField::create(_t('CheckoutField.MembershipDetails', 'Membership Details'), 3), LiteralField::create('MemberInfo', '<p class="message warning">' . _t('CheckoutField.MemberLoginInfo', 'If you are already a member please <a href="{LoginUrl}">log in</a>', '', array('LoginUrl' => $loginlink)) . '</p>'), LiteralField::create('AccountInfo', '<p>' . _t('CheckoutField.AccountInfo', 'Please choose a password, so you can login and check your order history in the future') . '</p>'), $pwf = $this->getPasswordField());
     if (!Checkout::user_membership_required()) {
         $pwf->setCanBeEmpty(true);
     }
     return $fields;
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:9,代码来源:CheckoutFieldFactory.php

示例12: getPasswordFields

 public function getPasswordFields()
 {
     $loginlink = "Security/login?BackURL=" . CheckoutPage::find_link(true);
     $fields = FieldList::create(HeaderField::create(_t('CheckoutField.MEMBERSHIPDETAILS', 'Membership Details'), 3), LiteralField::create('MemberInfo', '<p class="message warning">' . _t('CheckoutField.MEMBERINFO', 'If you are already a member please') . " <a href=\"{$loginlink}\">" . _t('OrderForm.LogIn', 'log in') . '</a>.' . '</p>'), LiteralField::create('AccountInfo', '<p>' . _t('CheckoutField.ACCOUNTINFO', 'Please choose a password, so you can login and check your order history in the future') . '</p>'), $this->getPasswordField());
     if (!Checkout::user_membership_required()) {
         $pwf->setCanBeEmpty(true);
     }
     return $fields;
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:9,代码来源:CheckoutFieldFactory.php

示例13: getData

 public function getData(Order $order)
 {
     $data = array();
     $gateway = Checkout::get($order)->getSelectedPaymentMethod();
     //provide valid dummy credit card data
     if ($gateway === "Dummy") {
         $data = array_merge(array('name' => 'Joe Bloggs', 'number' => '4242424242424242', 'cvv' => 123), $data);
     }
     return $data;
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:10,代码来源:OnsitePaymentCheckoutComponent.php

示例14: getGateway

 /**
  * @param Order $order
  *
  * @return \Omnipay\Common\AbstractGateway|\Omnipay\Braintree\Gateway
  */
 protected function getGateway($order)
 {
     if (!isset($this->gateway)) {
         $tempPayment = new Payment(['Gateway' => Checkout::get($order)->getSelectedPaymentMethod(false)]);
         $service = PurchaseService::create($tempPayment);
         $this->gateway = $service->oGateway();
         $this->isBraintree = $this->gateway instanceof \Omnipay\Braintree\Gateway;
     }
     return $this->gateway;
 }
开发者ID:markguinn,项目名称:silvershop-braintree,代码行数:15,代码来源:BraintreePaymentCheckoutComponent.php

示例15: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $copy_id = 1;
     $patron_id = 4;
     $due_date = "2015-09-03";
     $test_checkout = new Checkout($copy_id, $patron_id, $due_date);
     $test_checkout->save();
     $copy_id2 = 2;
     $patron_id2 = 1;
     $due_date2 = "2015-10-05";
     $test_checkout2 = new Checkout($copy_id2, $patron_id2, $due_date2);
     $test_checkout2->save();
     //Act
     Checkout::deleteAll();
     //Assert
     $result = Checkout::getAll();
     $this->assertEquals([], $result);
 }
开发者ID:alexdbrown,项目名称:library,代码行数:19,代码来源:CheckoutTest.php


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