public static function apply($type, &$total) { $user = JCck::getUser(); $my_groups = $user->getAuthorisedGroups(); $my_zones = JCckEcommerce::getUserZones(); $currency = JCckEcommerce::getCurrency(); $tax = ''; $taxes = JCckEcommerce::getTaxes($type, $my_zones); if (count($taxes)) { foreach ($taxes as $p) { $groups = explode(',', $p->groups); if (count(array_intersect($my_groups, $groups)) > 0) { switch ($p->tax) { case 'plus': $tax = $p->tax_amount; $total += $tax; break; case 'percentage': $tax = $total * $p->tax_amount / 100; $total += $tax; break; default: break; } } } } return $tax; }
public static function apply($type, &$total, $params = array()) { $user = JCck::getUser(); $my_groups = $user->getAuthorisedGroups(); $currency = JCckEcommerce::getCurrency(); $discount = ''; $promotions = JCckEcommerce::getPromotions($type); if (count($promotions)) { foreach ($promotions as $p) { if (isset($params['target']) && $params['target']) { if ($params['target'] == 'order' && $p->target == 0) { // OK } elseif ($params['target'] == 'product') { if ($p->target == 1) { // OK } elseif ($p->target == 2) { $products = self::getTargets($p->id); if (!isset($products[$params['target_id']])) { continue; } } elseif ($p->target == -2) { $products = self::getTargets($p->id); if (isset($products[$params['target_id']])) { continue; } } else { continue; } } else { continue; } } if ($p->type == 'coupon') { if ($p->code && $p->code != @$params['code']) { continue; } } $groups = explode(',', $p->groups); if (count(array_intersect($my_groups, $groups)) > 0) { switch ($p->discount) { case 'free': $discount = 'FREE'; $total = 0; break; case 'minus': $discount = '- ' . $currency->lft . $p->discount_amount . $currency->right; $total -= $p->discount_amount; break; case 'percentage': $discount = '- ' . $p->discount_amount . ' %'; $total = $total - $total * $p->discount_amount / 100; break; default: break; } } } } return $discount; }
public static function format($amount, $format = true) { if ($format) { $amount = number_format($amount, 2, JText::_('DECIMALS_SEPARATOR'), JText::_('THOUSANDS_SEPARATOR')); } $currency = JCckEcommerce::getCurrency(); return $currency->lft . $amount . $currency->rgt; }
public static function getCartDefinition($name) { static $definitions = array(); if (!isset($definitions[$name])) { $definitions[$name] = JCckDatabase::loadObject('SELECT title, name, storage_location, storage_table, storage_field, multicart, multistore, ordering, quantity, request_code, request_payment, request_payment_table, request_payment_field, request_shipping, request_shipping_field' . ' FROM #__cck_more_ecommerce_cart_definitions WHERE name = "' . $name . '"'); if (strpos($definitions[$name]->request_payment_field, '$') !== false) { $definitions[$name]->request_payment_field = str_replace('$', strtolower(JCckEcommerce::getCurrency()->code), $definitions[$name]->request_payment_field); } } return $definitions[$name]; }
public static function apply($type, &$total, $params = array()) { $user = JCck::getUser(); $my_groups = $user->groups; /* $user->getAuthorisedGroups(); */ $my_zones = JCckEcommerce::getUserZones(); $currency = JCckEcommerce::getCurrency(); $res = 0; $results = array('items' => array()); $tax = ''; $taxes = JCckEcommerce::getTaxes($type, $my_zones); if (count($taxes)) { foreach ($taxes as $p) { if (isset($params['target']) && $params['target']) { if ($params['target'] == 'order' && $p->target == 0) { // OK } elseif ($params['target'] == 'product' && $p->target == 1) { // OK } else { continue; } } $groups = explode(',', $p->groups); if (count(array_intersect($my_groups, $groups)) > 0) { switch ($p->tax) { case 'plus': $tax = $p->tax_amount; $res += $tax; $total += $tax; $results['items'][$p->id] = array('type' => $p->type, 'tax' => $p->tax, 'tax_amount' => (string) $tax, 'title' => $p->title); break; case 'percentage': $tax = $total * $p->tax_amount / 100; $res += $tax; $total += $tax; $results['items'][$p->id] = array('type' => $p->type, 'tax' => $p->tax, 'tax_amount' => (string) $tax, 'title' => $p->title); break; default: break; } } } } if ($res) { $results['total'] = (double) $res; return (object) $results; } return null; }
public static function format($amount) { $currency = JCckEcommerce::getCurrency(); return $currency->lft . $amount . $currency->rgt; }
public static function apply($type, &$total, $params = array()) { $user = JCck::getUser(); $my_groups = $user->groups; /* $user->getAuthorisedGroups(); */ $currency = JCckEcommerce::getCurrency(); $promotions = JCckEcommerce::getPromotions($type); $res = 0; $results = array('items' => array()); $text = ''; if (count($promotions)) { foreach ($promotions as $p) { if (isset($params['target']) && $params['target']) { if ($params['target'] == 'order' && $p->target == 0) { // OK } elseif ($params['target'] == 'product') { if ($p->target == 1) { // OK } elseif ($p->target == 2) { $products = self::getTargets($p->id); if (!isset($products[$params['target_id']])) { continue; } } elseif ($p->target == -2) { $products = self::getTargets($p->id); if (isset($products[$params['target_id']])) { continue; } } else { continue; } } else { continue; } } if ($p->type == 'coupon') { if ($p->code && $p->code != @$params['code']) { continue; } } $groups = explode(',', $p->groups); if (count(array_intersect($my_groups, $groups)) > 0) { switch ($p->discount) { case 'free': $promotion = 0; $res = $promotion; $text = JText::_('COM_CCK_FREE'); $total = $promotion; $results['items'][$p->id] = array('type' => $p->type, 'promotion' => $p->discount, 'promotion_amount' => '', 'text' => $text, 'title' => $p->title, 'code' => @(string) $params['code']); break; case 'minus': $promotion = $p->discount_amount * -1; $res += $promotion; $text = '- ' . JCckEcommerceCurrency::format($p->discount_amount); $total += $promotion; $total = $total < 0 ? 0 : $total; $results['items'][$p->id] = array('type' => $p->type, 'promotion' => $p->discount, 'promotion_amount' => (string) $promotion, 'text' => $text, 'title' => $p->title, 'code' => @(string) $params['code']); break; case 'percentage': $promotion = $total * $p->discount_amount / 100; $res = $promotion; $text = '- ' . $p->discount_amount . ' %'; $total = $total - $promotion; $results['items'][$p->id] = array('type' => $p->type, 'promotion' => $p->discount, 'promotion_amount' => (string) $promotion, 'text' => $text, 'title' => $p->title, 'code' => @(string) $params['code']); break; default: break; } } } } if ($res) { $results['text'] = $text; $results['total'] = (double) $res; return (object) $results; } return null; }