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


PHP Checkout::member_creation_enabled方法代码示例

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


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

示例1: 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

示例2: 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 = ValidationResult::create();
     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 ($member = ShopMember::get_by_identifier($idval)) {
         // get localized field labels
         $fieldLabels = $member->fieldLabels(false);
         // if a localized value exists, use this for our error-message
         $fieldLabel = isset($fieldLabels[$idfield]) ? $fieldLabels[$idfield] : $idfield;
         $result->error(sprintf(_t("Checkout.MEMBEREXISTS", "A member already exists with the %s %s"), $fieldLabel, $idval));
         throw new ValidationException($result);
     }
     $member = Member::create(Convert::raw2sql($data));
     // 3.2 changed validate to protected which made this fall through the DataExtension and error out
     $validation = $member->hasMethod('doValidate') ? $member->doValidate() : $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:NobrainerWeb,项目名称:silverstripe-shop,代码行数:47,代码来源:ShopMemberFactory.php

示例3: 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 = ValidationResult::create();
     if (!Checkout::member_creation_enabled()) {
         $result->error(_t("Checkout.MembershipIsNotAllowed", "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(_t('Checkout.IdFieldNotFound', 'Required field not found: {IdentifierField}', 'Identifier is the field that holds the unique user-identifier, commonly this is \'Email\'', array('IdentifierField' => $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 ($member = ShopMember::get_by_identifier($idval)) {
         // get localized field labels
         $fieldLabels = $member->fieldLabels(false);
         // if a localized value exists, use this for our error-message
         $fieldLabel = isset($fieldLabels[$idfield]) ? $fieldLabels[$idfield] : $idfield;
         $result->error(_t('Checkout.MemberExists', 'A member already exists with the {Field} {Identifier}', '', array('Field' => $fieldLabel, 'Identifier' => $idval)));
         throw new ValidationException($result);
     }
     $member = Member::create(Convert::raw2sql($data));
     // 3.2 changed validate to protected which made this fall through the DataExtension and error out
     $validation = $member->hasMethod('doValidate') ? $member->doValidate() : $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:burnbright,项目名称:silverstripe-shop,代码行数:47,代码来源:ShopMemberFactory.php

示例4: __construct

 public function __construct(Order $order)
 {
     parent::__construct($order);
     $this->addComponent(CustomerDetailsCheckoutComponent::create());
     $this->addComponent(ShippingAddressCheckoutComponent::create());
     $this->addComponent(BillingAddressCheckoutComponent::create());
     if (Checkout::member_creation_enabled() && !Member::currentUserID()) {
         $this->addComponent(MembershipCheckoutComponent::create());
     }
     if (count(GatewayInfo::getSupportedGateways()) > 1) {
         $this->addComponent(PaymentCheckoutComponent::create());
     }
     $this->addComponent(NotesCheckoutComponent::create());
     $this->addComponent(TermsCheckoutComponent::create());
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:15,代码来源:CheckoutComponentConfig.php


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