本文整理匯總了PHP中J2Store::cart方法的典型用法代碼示例。如果您正苦於以下問題:PHP J2Store::cart方法的具體用法?PHP J2Store::cart怎麽用?PHP J2Store::cart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類J2Store
的用法示例。
在下文中一共展示了J2Store::cart方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doLoginUser
private function doLoginUser($user, $options = array())
{
$app = JFactory::getApplication();
if ($app->isAdmin()) {
return true;
}
$session = JFactory::getSession();
$old_sessionid = $session->get('old_sessionid', '', 'j2store');
jimport('joomla.user.helper');
$user['id'] = intval(JUserHelper::getUserId($user['username']));
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/j2store.php';
//cart
$helper = J2Store::cart();
if (!empty($old_sessionid)) {
$helper->resetCart($old_sessionid, $user['id']);
//TODO do the same for wish lists
} else {
$helper->updateSession($user['id'], $session->getId());
}
return true;
}
示例2: getTotalCouponDiscount
public function getTotalCouponDiscount($coupon_info, $items)
{
$app = JFactory::getApplication();
$params = J2Store::config();
$session = JFactory::getSession();
$cart_helper = J2Store::cart();
$discount_total = 0;
if ($session->has('coupon', 'j2store')) {
$var = 'orderitem_finalprice_without_tax';
if (!$params->get('config_discount_before_tax', 1)) {
//discount applied after tax
$var = 'orderitem_finalprice_without_tax';
}
if (!$coupon_info->product) {
$sub_total = 0;
foreach ($items as $item) {
$sub_total += $item->{$var};
}
} else {
$sub_total = 0;
foreach ($items as $item) {
if (in_array($item->product_id, $coupon_info->product)) {
$sub_total += $item->{$var};
}
}
}
if ($coupon_info->value_type == 'F') {
$coupon_info->value = min($coupon_info->value, $sub_total);
}
$product_array2 = array();
foreach ($items as $item) {
$discount = 0;
if (!$coupon_info->product) {
$status = true;
} else {
if (in_array($item->product_id, $coupon_info->product)) {
$status = true;
} else {
$status = false;
}
}
if ($status) {
if ($coupon_info->value_type == 'F') {
$discount = $coupon_info->value * ($item->{$var} / $sub_total);
} elseif ($coupon_info->value_type == 'P') {
$discount = $item->{$var} / 100 * $coupon_info->value;
}
}
$discount_total += $discount;
}
if ($coupon_info->free_shipping && $session->has('shipping_values', 'j2store')) {
$shipping = $session->get('shipping_values', array(), 'j2store');
$shipping_cost = $shipping['shipping_price'] + $shipping['shipping_extra'] + $shipping['shipping_tax'];
$discount_total += $shipping_cost;
}
}
return $discount_total;
}
示例3: getTotal
/**
*
* Returns an object with the total cost of shipping for this method and the array of geozones
*
* @param unknown_type $shipping_method_id
* @param array $geozones
* @param unknown_type $orderItems
* @param unknown_type $order_id
*/
protected function getTotal($shipping_method_id, $geozones, $orderItems, $geozones_taxes)
{
$return = new JObject();
$return->j2store_shippingrate_id = '0';
$return->shipping_rate_price = '0.00000';
$return->shipping_rate_handling = '0.00000';
$return->shipping_tax_rates = '0.00000';
$return->shipping_tax_total = '0.00000';
$rate_exists = false;
$geozone_rates = array();
//include custom modals
$this->includeCustomModel('ShippingMethods');
$this->includeCustomModel('ShippingRates');
// cast product_id as an array
$orderItems = (array) $orderItems;
// determine the shipping method type
$this->includeCustomTables('shipping_standard');
$this->includeCustomTables();
$shippingmethod = F0FTable::getInstance('ShippingMethods', 'J2StoreTable');
$shippingmethod->load($shipping_method_id);
if (empty($shippingmethod->j2store_shippingmethod_id)) {
// TODO if this is an object, setError, otherwise return false, or 0.000?
$return->setError(JText::_('J2STORE_UNDEFINED_SHIPPING_METHOD'));
return $return;
}
//initiliase cart helper
$carthelper = J2Store::cart();
//initliase cart model
switch ($shippingmethod->shipping_method_type) {
case "2":
// 2 = per order - price based
// Get the total of the order, and find the rate for that
$total = 0;
//foreach ($orderItems as $item)
// {
// $total += $item->orderitem_final_price;
// }
$order_ships = false;
$params = J2Store::config();
if ($params->get('config_including_tax', 0)) {
$final_price = 'orderitem_finalprice_with_tax';
} else {
$final_price = 'orderitem_finalprice_without_tax';
}
foreach ($orderItems as $product) {
$registry = new JRegistry();
$registry->loadString($product->orderitem_params);
if ($registry->get('shipping', 0)) {
$order_ships = true;
$total += $product->{$final_price};
// product total
}
}
if ($order_ships) {
foreach ($geozones as $geozone) {
unset($rate);
$geozone_id = $geozone->geozone_id;
if (empty($geozone_rates[$geozone_id]) || !is_array($geozone_rates[$geozone_id])) {
$geozone_rates[$geozone_id] = array();
}
// JModelLegacy::addIncludePath( JPATH_ADMINISTRATOR.'/components/com_j2store/models' );
$model = F0FModel::getTmpInstance('ShippingRates', 'J2StoreModel');
$model->setState('filter_shippingmethod', $shipping_method_id);
$model->setState('filter_geozone', $geozone_id);
$model->setState('filter_weight', $total);
// Use weight as total
$items = $model->getList();
if (count($items) < 1) {
//return JTable::getInstance('ShippingRates', 'Table');
} else {
$rate = $items[0];
$geozone_rates[$geozone_id]['0'] = $rate;
// if $rate->j2store_shippingrate_id is empty, then no real rate was found
if (!empty($rate->j2store_shippingrate_id)) {
$rate_exists = true;
}
$geozone_rates[$geozone_id]['0']->qty = '1';
$geozone_rates[$geozone_id]['0']->shipping_method_type = $shippingmethod->shipping_method_type;
}
}
}
break;
case "1":
// 1 = per order - quantity based
// first, get the total quantity of shippable items for the entire order
// then, figure out the rate for this number of items (use the weight range field) + geozone
// 1 = per order - quantity based
// first, get the total quantity of shippable items for the entire order
// then, figure out the rate for this number of items (use the weight range field) + geozone
case "0":
// 0 = per order - flat rate
//.........這裏部分代碼省略.........