本文整理汇总了PHP中Isotope\Isotope::setCart方法的典型用法代码示例。如果您正苦于以下问题:PHP Isotope::setCart方法的具体用法?PHP Isotope::setCart怎么用?PHP Isotope::setCart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isotope\Isotope
的用法示例。
在下文中一共展示了Isotope::setCart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadOrderEnvironment
/**
* Initialize environment (language, objPage) for a given order
*
* @param Order $objOrder
* @param string $strLanguage
*/
public static function loadOrderEnvironment(Order $objOrder, $strLanguage = null)
{
global $objPage;
$strLanguage = $strLanguage ?: $objOrder->language;
// Load page configuration
if ($objOrder->pageId > 0 && (null === $objPage || $objPage->id != $objOrder->pageId)) {
$objPage = \PageModel::findWithDetails($objOrder->pageId);
$objPage = static::loadPageConfig($objPage);
}
// Set the current system to the language when the user placed the order.
// This will result in correct e-mails and payment description.
$GLOBALS['TL_LANGUAGE'] = $strLanguage;
\System::loadLanguageFile('default', $strLanguage, true);
Isotope::setConfig($objOrder->getRelated('config_id'));
if (($objCart = $objOrder->getRelated('source_collection_id')) !== null && $objCart instanceof Cart) {
Isotope::setCart($objCart);
}
}
示例2: processForm
protected function processForm()
{
// get a product collection (aka cart)
global $objPage;
$objCart = new Cart();
// Can't call the individual rows here, it would trigger markModified and a save()
$objCart->setRow(array_merge($objCart->row(), array('tstamp' => time(), 'member' => 0, 'uniqid' => null, 'config_id' => $this->iso_config_id, 'store_id' => (int) \PageModel::findByPk($objPage->rootId)->iso_store_id)));
$objSubmission = $this->getSubmission(false);
// add products to cart
foreach ($this->arrProducts as $arrProduct) {
$strProduct = 'product_' . $arrProduct['product']->id;
$strQuantity = 'quantity_' . $arrProduct['product']->id;
if (($this->getProductCount() > 1 || $this->getTypeCount() > 1) && !$objSubmission->{$strProduct}) {
continue;
}
if (!$objCart->addProduct($arrProduct['product'], $arrProduct['useQuantity'] ? $objSubmission->{$strQuantity} : 1)) {
$this->transformIsotopeErrorMessages();
return;
}
}
$objCart->save();
$objOrder = $objCart->getDraftOrder();
// temporarily override the cart for generating the reviews...
$objCartTmp = Isotope::getCart();
Isotope::setCart($objCart);
// create steps
$arrSteps = array();
$arrCheckoutInfo = array();
// billing address
$objBillingAddress = new Address();
foreach ($this->arrBillingAddressFields as $strName) {
$objBillingAddress->{$strName} = $objSubmission->{$strName};
}
$objBillingAddress->save();
$objOrder->setBillingAddress($objBillingAddress);
$objBillingAddressStep = new BillingAddress($this->objCheckoutModule);
$arrSteps[] = $objBillingAddressStep;
$arrCheckoutInfo['billing_address'] = $objBillingAddressStep->review()['billing_address'];
// shipping address
$objShippingAddress = new Address();
// standard isotope handling for distinguishing between the address types:
// -> if only a billing address is available, it's also the shipping address
foreach ($objSubmission->shippingaddress ? $this->arrShippingAddressFields : $this->arrBillingAddressFields as $strName) {
$objShippingAddress->{str_replace('shippingaddress_', '', $strName)} = $objSubmission->{$objSubmission->shippingaddress ? $strName : str_replace('shippingaddress_', 'billingaddress_', $strName)};
}
$objShippingAddress->save();
// $objOrder->setShippingAddress($objShippingAddress);
// $objShippingAddressStep = new ShippingAddress($this->objCheckoutModule);
// $arrSteps[] = $objShippingAddressStep;
// $arrCheckoutInfo['shipping_address'] = $objShippingAddressStep->review()['shipping_address'];
// add shipping method
$objIsotopeShipping = Flat::findByPk($this->iso_shipping_modules);
$objOrder->setShippingMethod($objIsotopeShipping);
$objShippingMethodStep = new ShippingMethod($this->objCheckoutModule);
$arrSteps[] = $objShippingMethodStep;
$arrCheckoutInfo['shipping_method'] = $objShippingMethodStep->review()['shipping_method'];
// add all the checkout info to the order
$objOrder->checkout_info = $arrCheckoutInfo;
$objOrder->notes = $objSubmission->notes;
//... restore the former cart again
Isotope::setCart($objCartTmp);
$objOrder->nc_notification = $this->nc_notification;
$objOrder->email_data = $this->getNotificationTokensFromSteps($arrSteps, $objOrder);
// !HOOK: pre-process checkout
if (isset($GLOBALS['ISO_HOOKS']['preCheckout']) && is_array($GLOBALS['ISO_HOOKS']['preCheckout'])) {
foreach ($GLOBALS['ISO_HOOKS']['preCheckout'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
if ($objCallback->{$callback}[1]($objOrder, $this->objCheckoutModule) === false) {
\System::log('Callback ' . $callback[0] . '::' . $callback[1] . '() cancelled checkout for Order ID ' . $this->id, __METHOD__, TL_ERROR);
$this->objCheckoutModule->redirectToStep('failed');
}
}
}
$objOrder->lock();
$objOrder->checkout();
$objOrder->complete();
if (is_array($this->dca['config']['onsubmit_callback'])) {
foreach ($this->dca['config']['onsubmit_callback'] as $key => $callback) {
if ($callback[0] == 'Isotope\\Backend\\ProductCollection\\Callback' && $callback[1] == 'executeSaveHook') {
unset($this->dca['config']['onsubmit_callback'][$key]);
break;
}
}
}
$this->transformIsotopeErrorMessages();
parent::processForm();
}
示例3: run
/**
* Run the controller
*/
public function run()
{
$objMethod = null;
try {
$strMod = $this->getModule();
$intId = $this->getModuleId();
if ($strMod == '' || $intId == 0) {
\System::log('Invalid post-sale request (param error): ' . \Environment::get('request'), __METHOD__, TL_ERROR);
$objResponse = new Response('Bad Request', 400);
$objResponse->send();
}
switch (strtolower($strMod)) {
case 'pay':
$objMethod = Payment::findByPk($intId);
break;
case 'ship':
$objMethod = Shipping::findByPk($intId);
break;
}
if (null === $objMethod) {
\System::log('Invalid post-sale request (model not found): ' . \Environment::get('request'), __METHOD__, TL_ERROR);
$objResponse = new Response('Not Found', 404);
$objResponse->send();
}
\System::log('New post-sale request: ' . \Environment::get('request'), __METHOD__, TL_ACCESS);
if (!$objMethod instanceof IsotopePostsale) {
\System::log('Invalid post-sale request (interface not implemented): ' . \Environment::get('request'), __METHOD__, TL_ERROR);
$objResponse = new Response('Not Implemented', 501);
$objResponse->send();
}
$objOrder = $objMethod->getPostsaleOrder();
if (null === $objOrder || !$objOrder instanceof IsotopeProductCollection) {
\System::log(get_class($objMethod) . ' did not return a valid order', __METHOD__, TL_ERROR);
$objResponse = new Response('Failed Dependency', 424);
$objResponse->send();
}
global $objPage;
// Load page configuration
if (!is_object($objPage) && $objOrder->pageId > 0) {
$objPage = \PageModel::findWithDetails($objOrder->pageId);
$objPage = \Isotope\Frontend::loadPageConfig($objPage);
}
// Set the current system to the language when the user placed the order.
// This will result in correct e-mails and payment description.
if ($GLOBALS['TL_LANGUAGE'] != $objOrder->language) {
$GLOBALS['TL_LANGUAGE'] = $objOrder->language;
\System::loadLanguageFile('default', $objOrder->language, true);
}
Isotope::setConfig($objOrder->getRelated('config_id'));
if (($objCart = $objOrder->getRelated('source_collection_id')) !== null && $objCart instanceof Cart) {
Isotope::setCart($objCart);
}
$objMethod->processPostsale($objOrder);
$objResponse = new Response();
$objResponse->send();
} catch (\Exception $e) {
\System::log(sprintf('Exception in post-sale request in file "%s" on line "%s" with message "%s".', $e->getFile(), $e->getLine(), $e->getMessage()), __METHOD__, TL_ERROR);
$objResponse = new Response('Internal Server Error', 500);
$objResponse->send();
}
}