本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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());
}