本文整理汇总了PHP中Checkout::verifyUserShippingDestination方法的典型用法代码示例。如果您正苦于以下问题:PHP Checkout::verifyUserShippingDestination方法的具体用法?PHP Checkout::verifyUserShippingDestination怎么用?PHP Checkout::verifyUserShippingDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Checkout
的用法示例。
在下文中一共展示了Checkout::verifyUserShippingDestination方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionShippingOptions
/**
* Display a radio button list of shipping options
* to the end user and process the chosen option
*
* @return void
*/
public function actionShippingOptions()
{
$this->publishJS('shipping');
$this->publishJS('zippo');
$this->layout = '/layouts/checkout';
$this->checkoutForm = MultiCheckoutForm::loadFromSessionOrNew();
// Check whether the user has selected a shipping option.
if (isset($_POST['MultiCheckoutForm'])) {
$this->checkoutForm->attributes = $_POST['MultiCheckoutForm'];
$this->checkoutForm->hasTaxModeChanged = false;
$this->checkoutForm->setScenario('ShippingOptions');
if ($this->checkoutForm->validate() === true) {
$this->checkoutForm->saveFormToSession();
// Update the cart shipping in the database.
// Update shipping. If in-store pickup was chosen then we need to
// ensure the cart shipping values are updated.
$objShipping = CartShipping::getOrCreateCartShipping();
if ($objShipping->hasErrors() === false) {
$objShipping->updateShipping();
$this->checkoutForm->addErrors($objShipping->getErrors());
} else {
$this->checkoutForm->addErrors($objShipping->getErrors());
}
$this->checkoutForm->passedScenario = $this->checkoutForm->getScenario();
$this->redirect($this->createUrl('/checkout/final'));
} else {
Yii::log(sprintf('Validation of the checkout form failed: %s', print_r($this->checkoutForm->getErrors(), true)), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
}
}
// In the case where the destination does not have a defined tax code,
// return to the shipping page with an error message.
if (Checkout::verifyUserShippingDestination($this->checkoutForm) === false) {
Yii::log(sprintf('Shipping destination is invalid: country=%s state=%s postal=%s', $this->checkoutForm->shippingCountryCode, $this->checkoutForm->shippingStateCode, $this->checkoutForm->shippingPostal), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
$this->redirect(array('/checkout/shipping', 'error-destination' => true));
return;
}
// Update the cart taxes prior to updating the cart scenarios.
Yii::app()->shoppingcart->setTaxCodeByCheckoutForm($this->checkoutForm);
$arrCartScenario = Shipping::loadCartScenariosFromSession();
// In the case where no shipping options are available, return to the
// shipping page with an error message.
// TODO: This isn't quite right. If store pickup is the only option, we
// also want to display this error because store pickup is not shown
// shown on the shipping options screen. See WS-3267.
if ($arrCartScenario === null || count($arrCartScenario) === 0) {
Yii::log(sprintf('No shipping options available: country=%s state=%s postal=%s', $this->checkoutForm->shippingCountryCode, $this->checkoutForm->shippingStateCode, $this->checkoutForm->shippingPostal), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
$this->redirect(array('/checkout/shipping', 'error-destination' => true));
return;
}
// Render the shipping options.
// The options themselves are loaded from the session.
// The implication here is that before redirecting to this page, ensure
// that the shipping options stored in the session are up to date.
$this->render('shippingoptions', array('model' => $this->checkoutForm, 'arrCartScenario' => $arrCartScenario, 'error' => $this->formatErrors()));
}