本文整理汇总了PHP中VirtueMartCart::_cart方法的典型用法代码示例。如果您正苦于以下问题:PHP VirtueMartCart::_cart方法的具体用法?PHP VirtueMartCart::_cart怎么用?PHP VirtueMartCart::_cart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtueMartCart
的用法示例。
在下文中一共展示了VirtueMartCart::_cart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCart
/**
*
* @author Max Milbers
* @param bool $setCart: set the Cart into Session
* @param array $options : options for getSession
* @param null $cartData: if not empty, do no get the cart data from session
* @return null|VirtueMartCart
*/
public static function getCart($setCart = true, $options = array())
{
//What does this here? for json stuff?
if (!class_exists('JTable')) {
require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table.php';
}
// JTable::addIncludePath(JPATH_VM_ADMINISTRATOR . DS . 'tables');
if (empty(self::$_cart)) {
$session = JFactory::getSession($options);
$cartSession = $session->get('vmcart', 0, 'vm');
if (!empty($cartSession)) {
$sessionCart = unserialize($cartSession);
self::$_cart = new VirtueMartCart();
self::$_cart->products = $sessionCart->products;
self::$_cart->vendorId = $sessionCart->vendorId;
self::$_cart->lastVisitedCategoryId = $sessionCart->lastVisitedCategoryId;
self::$_cart->virtuemart_shipmentmethod_id = $sessionCart->virtuemart_shipmentmethod_id;
self::$_cart->virtuemart_paymentmethod_id = $sessionCart->virtuemart_paymentmethod_id;
self::$_cart->automaticSelectedShipment = $sessionCart->automaticSelectedShipment;
self::$_cart->automaticSelectedPayment = $sessionCart->automaticSelectedPayment;
self::$_cart->BT = $sessionCart->BT;
self::$_cart->ST = $sessionCart->ST;
self::$_cart->tosAccepted = $sessionCart->tosAccepted;
self::$_cart->customer_comment = base64_decode($sessionCart->customer_comment);
self::$_cart->couponCode = $sessionCart->couponCode;
self::$_cart->_triesValidateCoupon = $sessionCart->_triesValidateCoupon;
self::$_cart->order_language = $sessionCart->order_language;
self::$_cart->cartData = $sessionCart->cartData;
self::$_cart->order_number = $sessionCart->order_number;
self::$_cart->lists = $sessionCart->lists;
//self::$_cart->pricesUnformatted = $sessionCart->pricesUnformatted;
self::$_cart->pricesCurrency = $sessionCart->pricesCurrency;
self::$_cart->paymentCurrency = $sessionCart->paymentCurrency;
self::$_cart->_inCheckOut = $sessionCart->_inCheckOut;
self::$_cart->_dataValidated = $sessionCart->_dataValidated;
self::$_cart->_confirmDone = $sessionCart->_confirmDone;
self::$_cart->STsameAsBT = $sessionCart->STsameAsBT;
self::$_cart->customer_number = $sessionCart->customer_number;
}
}
if (empty(self::$_cart)) {
self::$_cart = new VirtueMartCart();
}
if ($setCart == true) {
self::$_cart->setPreferred();
self::$_cart->setCartIntoSession();
}
return self::$_cart;
}
示例2: getCart
/**
* Get the cart from the session
*
* @author Max Milbers
* @access public
* @param array $cart the cart to store in the session
*/
public static function getCart($forceNew = false, $options = array(), $cartData = NULL)
{
//What does this here? for json stuff?
if (!class_exists('JTable')) {
require VMPATH_LIBS . DS . 'joomla' . DS . 'database' . DS . 'table.php';
}
if (empty(self::$_cart) or $forceNew) {
self::$_cart = new VirtueMartCart();
if (empty($cartData)) {
$session = JFactory::getSession($options);
$cartSession = $session->get('vmcart', 0, 'vm');
if (!empty($cartSession)) {
$sessionCart = (object) json_decode($cartSession, true);
if (empty($sessionCart->cartProductsData) or $sessionCart->_guest and $sessionCart->_guest != JFactory::getUser()->guest) {
self::$_cart->loadCart($sessionCart);
}
}
} else {
$cartSession = $sessionCart = $cartData;
}
$userModel = VmModel::getModel('user');
self::$_cart->user = $userModel->getCurrentUser();
$lang = JFactory::getLanguage();
self::$_cart->order_language = $lang->getTag();
if (!empty($cartSession)) {
if (isset($sessionCart->cartProductsData)) {
self::$_cart->cartProductsData = $sessionCart->cartProductsData;
self::$_cart->vendorId = $sessionCart->vendorId;
self::$_cart->lastVisitedCategoryId = $sessionCart->lastVisitedCategoryId;
self::$_cart->virtuemart_shipmentmethod_id = $sessionCart->virtuemart_shipmentmethod_id;
self::$_cart->virtuemart_paymentmethod_id = $sessionCart->virtuemart_paymentmethod_id;
self::$_cart->automaticSelectedShipment = $sessionCart->automaticSelectedShipment;
self::$_cart->automaticSelectedPayment = $sessionCart->automaticSelectedPayment;
self::$_cart->BT = $sessionCart->BT;
self::$_cart->ST = $sessionCart->ST;
self::$_cart->cartfields = $sessionCart->cartfields;
self::$_cart->couponCode = $sessionCart->couponCode;
self::$_cart->_triesValidateCoupon = $sessionCart->_triesValidateCoupon;
self::$_cart->order_number = $sessionCart->order_number;
self::$_cart->pricesCurrency = $sessionCart->pricesCurrency;
self::$_cart->paymentCurrency = $sessionCart->paymentCurrency;
self::$_cart->_guest = $sessionCart->_guest;
self::$_cart->_inCheckOut = $sessionCart->_inCheckOut;
self::$_cart->_inConfirm = $sessionCart->_inConfirm;
self::$_cart->_dataValidated = $sessionCart->_dataValidated;
self::$_cart->_confirmDone = $sessionCart->_confirmDone;
self::$_cart->STsameAsBT = $sessionCart->STsameAsBT;
self::$_cart->selected_shipto = $sessionCart->selected_shipto;
self::$_cart->_fromCart = $sessionCart->_fromCart;
self::$_cart->layout = $sessionCart->layout;
self::$_cart->layoutPath = $sessionCart->layoutPath;
self::$_cart->virtuemart_cart_id = $sessionCart->virtuemart_cart_id;
}
}
self::$_cart->loadSetRenderBTSTAddress();
if (empty(self::$_cart->virtuemart_shipmentmethod_id) && !empty(self::$_cart->user->virtuemart_shipmentmethod_id)) {
self::$_cart->virtuemart_shipmentmethod_id = self::$_cart->user->virtuemart_shipmentmethod_id;
}
if (empty(self::$_cart->virtuemart_paymentmethod_id) && !empty(self::$_cart->user->virtuemart_paymentmethod_id)) {
self::$_cart->virtuemart_paymentmethod_id = self::$_cart->user->virtuemart_paymentmethod_id;
}
if ((!empty(self::$_cart->user->tos) || !empty(self::$_cart->BT['tos'])) && !VmConfig::get('agree_to_tos_onorder', 0)) {
self::$_cart->BT['tos'] = 1;
}
if (!empty(self::$_cart->user->customer_number)) {
self::$_cart->customer_number = self::$_cart->user->customer_number;
}
if (empty(self::$_cart->customer_number) or strpos(self::$_cart->customer_number, 'nonreg_') !== FALSE) {
$firstName = empty(self::$_cart->BT['first_name']) ? '' : self::$_cart->BT['first_name'];
$lastName = empty(self::$_cart->BT['last_name']) ? '' : self::$_cart->BT['last_name'];
$email = empty(self::$_cart->BT['email']) ? '' : self::$_cart->BT['email'];
self::$_cart->customer_number = 'nonreg_' . $firstName . $lastName . $email;
}
$multixcart = VmConfig::get('multixcart', 0);
if (!empty($multixcart)) {
if ($multixcart == 'byvendor' or self::$_cart->vendorId == 1) {
$vendor = VmModel::getModel('vendor');
$vId = $vendor->getLoggedVendor();
if (!empty($vId) and $vId != 1) {
self::$_cart->vendorId = $vId;
}
if (empty(self::$_cart->vendorId)) {
self::$_cart->vendorId = 1;
}
}
if ($multixcart == 'byselection') {
self::$_cart->vendorId = vRequest::getInt('virtuemart_vendor_id', self::$_cart->vendorId);
}
}
//We need to check for the amount of products. A cart in Multix mode using the first product
// to determine the vendorId is a valid if there is no product in the cart
if (count(self::$_cart->cartProductsData) > 0 and empty(self::$_cart->vendorId)) {
self::$_cart->vendorId = 1;
//.........这里部分代码省略.........
示例3: getCart
/**
* Get the cart from the session
*
* @author Max Milbers
* @access public
* @param array $cart the cart to store in the session
*/
public static function getCart($setCart = true, $options = array())
{
if (empty(self::$_cart)) {
$session = JFactory::getSession($options);
$cartSession = $session->get('vmcart', 0, 'vm');
self::$_cart = new VirtueMartCart();
if (!empty($cartSession)) {
$sessionCart = unserialize($cartSession);
foreach (self::$sessionKeys as $k) {
self::$_cart->{$k} = $sessionCart->{$k};
}
self::$_cart->customer_comment = base64_decode($sessionCart->customer_comment);
}
}
if ($setCart == true) {
self::$_cart->setPreferred();
self::$_cart->setCartIntoSession();
}
return self::$_cart;
}
示例4: getCart
/**
* Get the cart from the session
*
* @author Max Milbers
* @access public
* @param array $cart the cart to store in the session
*/
public static function getCart($setCart = true, $options = array(), $cartData = NULL)
{
//What does this here? for json stuff?
if (!class_exists('JTable')) {
require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table.php';
}
if (empty(self::$_cart)) {
self::$_cart = new VirtueMartCart();
if (empty($cartData)) {
$session = JFactory::getSession($options);
$cartSession = $session->get('vmcart', 0, 'vm');
if (!empty($cartSession)) {
$sessionCart = unserialize($cartSession);
if (empty($sessionCart->cartProductsData) or $sessionCart->_guest and $sessionCart->_guest != JFactory::getUser()->guest) {
self::$_cart->loadCart($sessionCart);
}
}
} else {
$cartSession = $cartData;
$sessionCart = unserialize($cartSession);
}
$userModel = VmModel::getModel('user');
self::$_cart->user = $userModel->getCurrentUser();
$lang = JFactory::getLanguage();
self::$_cart->order_language = $lang->getTag();
if (!empty($cartSession)) {
if (isset($sessionCart->cartProductsData)) {
self::$_cart->cartProductsData = $sessionCart->cartProductsData;
self::$_cart->vendorId = $sessionCart->vendorId;
self::$_cart->lastVisitedCategoryId = $sessionCart->lastVisitedCategoryId;
self::$_cart->virtuemart_shipmentmethod_id = $sessionCart->virtuemart_shipmentmethod_id;
self::$_cart->virtuemart_paymentmethod_id = $sessionCart->virtuemart_paymentmethod_id;
self::$_cart->automaticSelectedShipment = $sessionCart->automaticSelectedShipment;
self::$_cart->automaticSelectedPayment = $sessionCart->automaticSelectedPayment;
self::$_cart->BT = $sessionCart->BT;
self::$_cart->ST = $sessionCart->ST;
self::$_cart->cartfields = $sessionCart->cartfields;
self::$_cart->couponCode = $sessionCart->couponCode;
self::$_cart->_triesValidateCoupon = $sessionCart->_triesValidateCoupon;
self::$_cart->order_number = $sessionCart->order_number;
self::$_cart->pricesCurrency = $sessionCart->pricesCurrency;
self::$_cart->paymentCurrency = $sessionCart->paymentCurrency;
self::$_cart->_guest = $sessionCart->_guest;
self::$_cart->_inCheckOut = $sessionCart->_inCheckOut;
self::$_cart->_inConfirm = $sessionCart->_inConfirm;
self::$_cart->_dataValidated = $sessionCart->_dataValidated;
self::$_cart->_confirmDone = $sessionCart->_confirmDone;
self::$_cart->STsameAsBT = $sessionCart->STsameAsBT;
self::$_cart->selected_shipto = $sessionCart->selected_shipto;
self::$_cart->_fromCart = $sessionCart->_fromCart;
}
}
self::$_cart->loadSetRenderBTSTAddress();
if (empty(self::$_cart->virtuemart_shipmentmethod_id) && !empty(self::$_cart->user->virtuemart_shipmentmethod_id)) {
self::$_cart->virtuemart_shipmentmethod_id = self::$_cart->user->virtuemart_shipmentmethod_id;
}
if (empty(self::$_cart->virtuemart_paymentmethod_id) && !empty(self::$_cart->user->virtuemart_paymentmethod_id)) {
self::$_cart->virtuemart_paymentmethod_id = self::$_cart->user->virtuemart_paymentmethod_id;
}
if ((!empty(self::$_cart->user->agreed) || !empty(self::$_cart->BT['agreed'])) && !VmConfig::get('agree_to_tos_onorder', 0)) {
self::$_cart->BT['tos'] = 1;
}
//if(empty($this->customer_number) or ($this->user->virtuemart_user_id!=0 and strpos($this->customer_number,'nonreg_')!==FALSE ) ){
if (self::$_cart->user->virtuemart_user_id != 0 and empty(self::$_cart->customer_number) or strpos(self::$_cart->customer_number, 'nonreg_') !== FALSE) {
self::$_cart->customer_number = $userModel->getCustomerNumberById();
}
if (empty(self::$_cart->customer_number) or strpos(self::$_cart->customer_number, 'nonreg_') !== FALSE) {
$firstName = empty(self::$_cart->BT['first_name']) ? '' : self::$_cart->BT['first_name'];
$lastName = empty(self::$_cart->BT['last_name']) ? '' : self::$_cart->BT['last_name'];
$email = empty(self::$_cart->BT['email']) ? '' : self::$_cart->BT['email'];
self::$_cart->customer_number = 'nonreg_' . $firstName . $lastName . $email;
}
$multixcart = VmConfig::get('multixcart', 0);
if (!empty($multixcart)) {
if ($multixcart == 'byvendor' and empty(self::$_cart->vendorId) or self::$_cart->vendorId == 1) {
$vendor = VmModel::getModel('vendor');
self::$_cart->vendorId = $vendor->getLoggedVendor();
if (empty(self::$_cart->vendorId)) {
self::$_cart->vendorId = 1;
}
}
if ($multixcart == 'byselection') {
self::$_cart->vendorId = vRequest::get('virtuemart_vendor_id', 1);
}
} else {
self::$_cart->vendorId = 1;
}
vmdebug('getCart $_cart->vendorId', self::$_cart->vendorId);
}
return self::$_cart;
}