本文整理汇总了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;
}
示例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) {
}
}
示例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]);
}
示例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);
}
示例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;
}
示例7: tearDown
protected function tearDown()
{
Author::deleteAll();
Book::deleteAll();
Checkout::deleteAll();
Patron::deleteAll();
}
示例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);
}
示例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;
}
示例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');
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}