コード例 #1
0
ファイル: custom_price.php プロジェクト: q0821/esportshop
 function hikashop_product_price_for_quantity_in_cart(&$product)
 {
     $currencyClass = hikashop_get('class.currency');
     $quantity = @$product->cart_product_quantity;
     $plugin = JPluginHelper::getPlugin('system', 'custom_price');
     if (version_compare(JVERSION, '2.5', '<')) {
         jimport('joomla.html.parameter');
         $params = new JParameter($plugin->params);
     } else {
         $params = new JRegistry($plugin->params);
     }
     $taxes = $params->get('taxes', 0);
     $column = $params->get('field', 'amount');
     if (!empty($product->{$column})) {
         if (empty($product->prices)) {
             $price = new stdClass();
             $price->price_currency_id = hikashop_getCurrency();
             $price->price_min_quantity = 1;
             $product->prices = array($price);
         }
         foreach ($product->prices as $k => $price) {
             if ($taxes && $product->product_type == 'variant' && empty($product->product_tax_id)) {
                 $productClass = hikashop_get('class.product');
                 $main = $productClass->get($product->product_parent_id);
                 $product->product_tax_id = $main->product_tax_id;
             }
             switch ($taxes) {
                 case 2:
                     $product->prices[$k]->price_value = $currencyClass->getUntaxedPrice($product->{$column}, hikashop_getZone(), $product->product_tax_id);
                     $product->prices[$k]->taxes = $currencyClass->taxRates;
                     $product->prices[$k]->price_value_with_tax = $product->{$column};
                     break;
                 case 1:
                     $product->prices[$k]->price_value = $product->{$column};
                     $product->prices[$k]->price_value_with_tax = $currencyClass->getTaxedPrice($product->{$column}, hikashop_getZone(), $product->product_tax_id);
                     $product->prices[$k]->taxes = $currencyClass->taxRates;
                     break;
                 case 0:
                 default:
                     $product->prices[$k]->price_value = $product->{$column};
                     $product->prices[$k]->price_value_with_tax = $product->{$column};
                     break;
             }
         }
     }
     $currencyClass->quantityPrices($product->prices, $quantity, $product->cart_product_total_quantity);
 }
コード例 #2
0
ファイル: aupost.php プロジェクト: q0821/esportshop
 function onShippingDisplay(&$order, &$dbrates, &$usable_rates, &$messages)
 {
     if (!hikashop_loadUser()) {
         return false;
     }
     if ($this->loadShippingCache($order, $usable_rates, $messages)) {
         return true;
     }
     $local_usable_rates = array();
     $local_messages = array();
     $currencyClass = hikashop_get('class.currency');
     $ret = parent::onShippingDisplay($order, $dbrates, $local_usable_rates, $local_messages);
     if ($ret === false) {
         return false;
     }
     $cache_usable_rates = array();
     $cache_messages = array();
     $currentCurrencyId = null;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $iAmSuperAdmin = false;
     if (!HIKASHOP_J16) {
         $iAmSuperAdmin = $user->get('gid') == 25;
     } else {
         $iAmSuperAdmin = $user->authorise('core.admin');
     }
     if ($iAmSuperAdmin) {
         $app->enqueueMessage('That Australia Post shipping version is deprecated and is using the old Australia post API, Please start using the new Australia Post v2 shipping method');
     }
     foreach ($local_usable_rates as $rate) {
         if (!empty($rate->shipping_zone_namekey)) {
             if (empty($rate->shipping_params->SEA) && empty($rate->shipping_params->AIR) && !empty($order->shipping_address->address_country)) {
                 $db = JFactory::getDBO();
                 if (is_array($order->shipping_address->address_country)) {
                     $address_country = reset($order->shipping_address->address_country);
                 } else {
                     $address_country = $order->shipping_address->address_country;
                 }
                 $db->setQuery('SELECT * FROM ' . hikashop_table('zone') . ' WHERE zone_namekey=' . $db->Quote($address_country));
                 $currentShippingZone = $db->loadObject();
                 if ($currentShippingZone->zone_code_3 != 'AUS') {
                     $messages['no_shipping_to_your_zone'] = JText::_('NO_SHIPPING_TO_YOUR_ZONE');
                     continue;
                 }
             }
         }
         $check = false;
         if (empty($order->shipping_address->address_post_code)) {
             $check = true;
             $message = 'The Australia Post shipping plugin requires the user to enter a postal code when goods are shipped within Australia. Please go to "Display->Custom fields" and set the post code field to required.';
         } elseif (!preg_match('#[0-9]{4}#', $order->shipping_address->address_post_code)) {
             $check = true;
             $message = 'The post code entered is not valid';
             $order->shipping_address->address_post_code = preg_replace('#[^0-9A-Z]#', '', $order->shipping_address->address_post_code);
         }
         if ($check) {
             $zoneClass = hikashop_get('class.zone');
             $zones = $zoneClass->getOrderZones($order);
             $db = JFactory::getDBO();
             $db->setQuery('SELECT zone_namekey FROM ' . hikashop_table('zone') . ' WHERE zone_code_3=' . $db->Quote('AUS'));
             $australia_zone = $db->loadResult();
             if (in_array($australia_zone, $zones)) {
                 $cache_messages['post_code_missing'] = $message;
                 continue;
             }
         }
         if (empty($order->shipping_address_full)) {
             $cart = hikashop_get('class.cart');
             $address = $app->getUserState(HIKASHOP_COMPONENT . '.shipping_address');
             $cart->loadAddress($order->shipping_address_full, $address, 'object', 'shipping');
         }
         $rates = array();
         $this->getRates($rate, $order, $rates);
         if (!empty($rate->shipping_params->reverse_order)) {
             $rates = array_reverse($rates, true);
         }
         foreach ($rates as $finalRate) {
             if (hikashop_getCurrency() != 6) {
                 $finalRate->shipping_price = $currencyClass->convertUniquePrice($finalRate->shipping_price, 6, hikashop_getCurrency());
             }
             $usable_rates[$finalRate->shipping_id] = $finalRate;
             $cache_usable_rates[$finalRate->shipping_id] = $finalRate;
         }
     }
     $this->setShippingCache($order, $cache_usable_rates, $cache_messages);
     if (!empty($cache_messages)) {
         foreach ($cache_messages as $k => $msg) {
             $messages[$k] = $msg;
         }
     }
     return true;
 }
コード例 #3
0
ファイル: shipping.php プロジェクト: q0821/esportshop
 function getShippingProductsData(&$order, $products = array())
 {
     if (empty($order->shipping_prices)) {
         $order->shipping_prices = array();
     }
     if (!isset($order->shipping_prices[0])) {
         $order->shipping_prices[0] = new stdClass();
         $order->shipping_prices[0]->all_with_tax = 0;
         $order->shipping_prices[0]->all_without_tax = 0;
         if (isset($order->total->prices[0]->price_value_with_tax)) {
             $order->shipping_prices[0]->all_with_tax = $order->total->prices[0]->price_value_with_tax;
         }
         if (isset($order->full_total->prices[0]->price_value_without_shipping_with_tax)) {
             $order->shipping_prices[0]->all_with_tax = $order->full_total->prices[0]->price_value_without_shipping_with_tax;
         }
         if (isset($order->total->prices[0]->price_value)) {
             $order->shipping_prices[0]->all_without_tax = $order->total->prices[0]->price_value;
         }
         if (isset($order->full_total->prices[0]->price_value_without_shipping)) {
             $order->shipping_prices[0]->all_without_tax = $order->full_total->prices[0]->price_value_without_shipping;
         }
         $order->shipping_prices[0]->weight = @$order->weight;
         $order->shipping_prices[0]->volume = @$order->volume;
         $order->shipping_prices[0]->total_quantity = @$order->total_quantity;
     }
     $key = 0;
     if (!empty($products)) {
         $product_keys = array_keys($products);
         sort($product_keys);
         $key = implode(',', $product_keys);
         if (!isset($order->shipping_prices[$key])) {
             $order->shipping_prices[$key] = new stdClass();
         }
     }
     $order->shipping_prices[$key]->real_with_tax = 0.0;
     $order->shipping_prices[$key]->real_without_tax = 0.0;
     $order->shipping_prices[$key]->products = array();
     $order->shipping_prices[$key]->volume = 0.0;
     $order->shipping_prices[$key]->weight = 0.0;
     $order->shipping_prices[$key]->total_quantity = 0;
     if (!empty($order->products)) {
         $all_products = new stdClass();
         $all_products->products = array();
         $real_products = new stdClass();
         $real_products->products = array();
         $volumeClass = hikashop_get('helper.volume');
         $weightClass = hikashop_get('helper.weight');
         foreach ($order->products as $k => $row) {
             if (!empty($products) && !isset($products[$k])) {
                 continue;
             }
             if (empty($order->shipping_prices[$key]->products[$row->product_id])) {
                 $order->shipping_prices[$key]->products[$row->product_id] = 0;
             }
             $order->shipping_prices[$key]->products[$row->product_id] += @$row->cart_product_quantity;
             if (!empty($row->product_parent_id)) {
                 if (!isset($order->shipping_prices[$key]->products[$row->product_parent_id])) {
                     $order->shipping_prices[$key]->products[$row->product_parent_id] = 0;
                 }
                 $order->shipping_prices[$key]->products[$row->product_parent_id] += @$row->cart_product_quantity;
             }
             if (@$row->product_weight > 0) {
                 $real_products->products[] = $row;
             }
             if ($key !== 0) {
                 $all_products->products[] = $row;
             }
             if ($key !== 0 && !empty($row->cart_product_quantity)) {
                 if (!empty($row->cart_product_parent_id)) {
                     if (!bccomp($row->product_length, 0, 5) || !bccomp($row->product_width, 0, 5) || !bccomp($row->product_height, 0, 5)) {
                         foreach ($order->products as $l => $elem) {
                             if ($elem->cart_product_id == $row->cart_product_parent_id) {
                                 $row->product_length = $elem->product_length;
                                 $row->product_width = $elem->product_width;
                                 $row->product_height = $elem->product_height;
                                 $row->product_dimension_unit = $elem->product_dimension_unit;
                                 break;
                             }
                         }
                     }
                     if (!bccomp($row->product_weight, 0, 5)) {
                         foreach ($order->products as $l => $elem) {
                             if ($elem->cart_product_id == $row->cart_product_parent_id) {
                                 $row->product_weight = $elem->product_weight;
                                 $row->product_weight_unit = $elem->product_weight_unit;
                                 break;
                             }
                         }
                     }
                 }
                 if (bccomp($row->product_length, 0, 5) && bccomp($row->product_width, 0, 5) && bccomp($row->product_height, 0, 5)) {
                     if (!isset($row->product_total_volume)) {
                         $row->product_volume = $row->product_length * $row->product_width * $row->product_height;
                         $row->product_total_volume = $row->product_volume * $row->cart_product_quantity;
                         $row->product_total_volume_orig = $row->product_total_volume;
                         $row->product_dimension_unit_orig = $row->product_dimension_unit;
                         $row->product_total_volume = $volumeClass->convert($row->product_total_volume, $row->product_dimension_unit);
                         $row->product_dimension_unit = $order->volume_unit;
                     }
                     $order->shipping_prices[$key]->volume += $row->product_total_volume;
                 }
                 if (bccomp($row->product_weight, 0, 5)) {
                     if ($row->product_weight_unit != $order->weight_unit) {
                         $row->product_weight_orig = $row->product_weight;
                         $row->product_weight_unit_orig = $row->product_weight_unit;
                         $row->product_weight = $weightClass->convert($row->product_weight, $row->product_weight_unit);
                         $row->product_weight_unit = $order->weight_unit;
                     }
                     $order->shipping_prices[$key]->weight += $row->product_weight * $row->cart_product_quantity;
                 }
                 $order->shipping_prices[$key]->total_quantity += $row->cart_product_quantity;
             }
         }
         $currencyClass = hikashop_get('class.currency');
         $currencyClass->calculateTotal($real_products->products, $real_products->total, hikashop_getCurrency());
         $order->shipping_prices[$key]->real_with_tax = $real_products->total->prices[0]->price_value_with_tax;
         $order->shipping_prices[$key]->real_without_tax = $real_products->total->prices[0]->price_value;
         if ($key !== 0) {
             $currencyClass->calculateTotal($all_products->products, $all_products->total, hikashop_getCurrency());
             $order->shipping_prices[$key]->all_with_tax = $all_products->total->prices[0]->price_value_with_tax;
             $order->shipping_prices[$key]->all_without_tax = $all_products->total->prices[0]->price_value;
             if (!empty($order->coupon)) {
                 if ($order->coupon->discount_flat_amount != 0) {
                     $order->shipping_prices[$key]->all_with_tax -= $order->coupon->discount_flat_amount;
                     $order->shipping_prices[$key]->all_without_tax -= $order->coupon->discount_flat_amount;
                 } elseif ($order->coupon->discount_percent_amount != 0) {
                     $order->shipping_prices[$key]->all_with_tax -= $order->shipping_prices[$key]->all_with_tax * ($order->coupon->discount_percent_amount / 100);
                     $order->shipping_prices[$key]->all_without_tax -= $order->shipping_prices[$key]->all_without_tax * ($order->coupon->discount_percent_amount / 100);
                 }
             }
         }
         unset($real_products->products);
         unset($real_products);
     }
     return $key;
 }
コード例 #4
0
 function onHikashopAfterDisplayView(&$view)
 {
     $option = JRequest::getString('option');
     $ctrl = JRequest::getString('ctrl');
     $task = JRequest::getString('task');
     if ($option != 'com_hikashop' || $ctrl != 'product' || $task != 'show') {
         return;
     }
     $config =& hikashop_config();
     $default_params = $config->get('default_params');
     $product_page = ob_get_clean();
     $product_page_parts = explode('class="hikashop_product_page ', $product_page);
     if (!empty($product_page_parts[1])) {
         $product_page_parts[1] = 'itemscope itemtype="http://schema.org/Product" class="hikashop_product_page ' . $product_page_parts[1];
         $pattern = '/id="hikashop_product_name_main"/';
         $replacement = 'id="hikashop_product_name_main" itemprop="name"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $pattern = '/id="hikashop_product_code_main"/';
         $replacement = 'id="hikashop_product_code_main" itemprop="sku"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         if ($default_params['show_price'] == 1) {
             $currency_id = hikashop_getCurrency();
             $null = null;
             $currencyClass = hikashop_get('class.currency');
             $currencies = $currencyClass->getCurrencies($currency_id, $null);
             $data = $currencies[$currency_id];
             $pattern = '/<span id="hikashop_product_price_main" class="hikashop_product_price_main">/';
             $replacement = '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span id="hikashop_product_price_main" class="hikashop_product_price_main"><meta itemprop="priceCurrency" content="' . $data->currency_code . '" />';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
             $pattern = '/<(span|div) id="(hikashop_product_weight_main|hikashop_product_width_main|hikashop_product_length_main|hikashop_product_height_main|hikashop_product_characteristics|hikashop_product_options|hikashop_product_custom_item_info|hikashop_product_price_with_options_main|hikashop_product_quantity_main)"/';
             $replacement = '</div> <$1 id="$2"';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
             $pattern = '/class="hikashop_product_price_main"(.*)class="hikashop_product_price hikashop_product_price_0/msU';
             $replacement = 'class="hikashop_product_price_main" $1 itemprop="price" class="hikashop_product_price hikashop_product_price_0';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
             $pattern = '/class="hikashop_product_price_per_unit"/';
             $replacement = 'class="hikashop_product_price_per_unit" itemprop="eligibleQuantity"';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         }
         $pattern = '/id="hikashop_product_vote_listing"/';
         $replacement = 'id="hikashop_product_vote_listing" itemscope itemtype="http://schema.org/Review"';
         if (strpos($product_page_parts[1], 'class="hika_comment_listing_empty"') == false) {
             $pattern = '/class="ui-corner-all hika_comment_listing"/';
             $replacement = 'class="ui-corner-all hika_comment_listing" itemprop="review" itemscope itemtype="http://schema.org/Review"';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         }
         $pattern = '/class="hikashop_vote_listing_comment"/';
         $replacement = 'class="hikashop_vote_listing_comment" itemprop="description"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hika_comment_listing_content"/';
         $replacement = 'class="hika_comment_listing_content" itemprop="description"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hika_comment_listing_name"/';
         $replacement = 'class="hika_comment_listing_name" itemprop="author" itemscope itemtype="http://schema.org/Person"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hikashop_vote_listing_username"/';
         $replacement = 'class="hikashop_vote_listing_username" itemprop="name"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hika_vote_listing_username"/';
         $replacement = 'class="hika_vote_listing_username" itemprop="name"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hikashop_product_description_main"/';
         $replacement = 'class="hikashop_product_description_main" itemprop="description"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $pattern = '/class="hikashop_vote_stars"/';
         $replacement = 'class="hikashop_vote_stars" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $pattern = '/id="hikashop_main_image"/';
         $replacement = 'id="hikashop_main_image" itemprop="image"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1]);
         $pattern = '/class="hikashop_product_width_main"/';
         $replacement = 'class="hikashop_product_width_main" itemprop="width"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $pattern = '/class="hikashop_product_height_main"/';
         $replacement = 'class="hikashop_product_height_main" itemprop="height"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $pattern = '/class="hikashop_product_length_main"/';
         $replacement = 'class="hikashop_product_length_main" itemprop="length"';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         $ratemax = JRequest::getVar("nb_max_star");
         //nbmax
         $pattern = '/(<span\\s+class="hikashop_total_vote")/iUs';
         preg_match('/<input type="hidden" class="hikashop_vote_rating".*data-rate="(.*)"/U', $product_page_parts[1], $matches);
         if (isset($matches[1])) {
             $replacement = '<span style="display:none" itemprop="ratingValue">' . $matches[1] . '</span><span style="display:none" itemprop="bestRating">' . $ratemax . '</span><span style="display:none" itemprop="worstRating">1</span>$1';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         }
         preg_match('/<span class="hikashop_total_vote">.*>(.*)</U', $product_page_parts[1], $matches);
         if (isset($matches[1])) {
             $replacement = '<span style="display:none" itemprop="reviewCount">' . trim($matches[1]) . '</span>$1';
             $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
         }
         $pattern = '/itemprop="keywords"/';
         $replacement = '';
         $product_page_parts[1] = preg_replace($pattern, $replacement, $product_page_parts[1], 1);
     }
     foreach ($product_page_parts as $parts) {
         echo $parts;
     }
 }
コード例 #5
0
ファイル: hikashop.php プロジェクト: Giftd/giftd-joomla
 static function getCartSumm()
 {
     $config =& hikashop_config();
     $main_currency = (int) $config->get('main_currency', 1);
     $zone_id = hikashop_getZone('shipping');
     if ($config->get('tax_zone_type', 'shipping') == 'billing') {
         $tax_zone_id = hikashop_getZone('billing');
     } else {
         $tax_zone_id = $zone_id;
     }
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $cart = hikashop_get('class.cart');
     $cartInfo = $cart->loadCart();
     $cart_id = $cartInfo->cart_id;
     if ($cart_id == 0) {
         return 0;
     }
     $products = $cart->get($cart_id);
     $total = null;
     $currencyClass = hikashop_get('class.currency');
     $currency_id = hikashop_getCurrency();
     $ids = array();
     $mainIds = array();
     foreach ($products as $product) {
         $ids[] = $product->product_id;
     }
     $currencyClass->getPrices($products, $ids, $currency_id, $main_currency, $tax_zone_id, $discount_before_tax);
     foreach ($products as $k => $row) {
         unset($products[$k]->cart_modified);
         unset($products[$k]->cart_coupon);
         $currencyClass->calculateProductPriceForQuantity($products[$k]);
     }
     $currencyClass->calculateTotal($products, $total, $currency_id);
     if (isset($total->prices) && isset($total->prices[0]) && isset($total->prices[0]->price_value) && !empty($total->prices[0]->price_value)) {
         $sum = $total->prices[0]->price_value;
     } else {
         $sum = 0;
     }
     return $sum;
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: rodhoff/MNW
 function compare()
 {
     if (!hikashop_level(2)) {
         return;
     }
     $app = JFactory::getApplication();
     $cids = JRequest::getVar('cid', array(), '', 'array');
     $config =& hikashop_config();
     $this->assignRef('config', $config);
     global $Itemid;
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (empty($menu)) {
         if (!empty($Itemid)) {
             $menus->setActive($Itemid);
             $menu = $menus->getItem($Itemid);
         }
     }
     if (empty($cids)) {
         if (is_object($menu)) {
             jimport('joomla.html.parameter');
             $category_params = new HikaParameter($menu->params);
             $cids = $category_params->get('product_id');
             if (!is_array($cids)) {
                 $cids = array($cids);
             }
             foreach ($cids as $k => $cid) {
                 if ($k > 7) {
                     unset($cids[$k]);
                 }
             }
         }
     }
     if (empty($cids)) {
         return;
     }
     $c = array();
     foreach ($cids as $cid) {
         if (strpos($cid, ',') !== false) {
             $c = array_merge($c, explode(',', $cid));
         } else {
             $c[] = (int) $cid;
         }
     }
     $cids = $c;
     JArrayHelper::toInteger($cids);
     $empty = '';
     $default_params = $config->get('default_params');
     jimport('joomla.html.parameter');
     $params = new HikaParameter($empty);
     foreach ($default_params as $k => $param) {
         $params->set($k, $param);
     }
     $main_currency = (int) $config->get('main_currency', 1);
     $params->set('main_currency', $main_currency);
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $params->set('discount_before_tax', $discount_before_tax);
     $params->set('show_compare', (int) $config->get('show_compare', 0));
     $compare_limit = (int) $config->get('compare_limit', 5);
     $params->set('compare_limit', $compare_limit);
     $compare_inc_lastseen = (int) $config->get('compare_inc_lastseen', 0);
     $params->set('compare_inc_lastseen', $compare_inc_lastseen);
     $params->set('compare_show_name_separator', (int) $config->get('compare_show_name_separator', 1));
     $params->set('catalogue', (int) $config->get('catalogue', 0));
     $params->set('add_to_cart', (int) 1);
     $params->set('show_price_weight', (int) $config->get('show_price_weight', 0));
     $params->set('characteristic_display', $config->get('characteristic_display', 'table'));
     $params->set('characteristic_display_text', $config->get('characteristic_display_text', 1));
     $params->set('show_quantity_field', $config->get('show_quantity_field', 1));
     $this->assignRef('params', $params);
     if (count($cids) > $compare_limit) {
         $cids = array_slice($cids, 0, $compare_limit);
     }
     $filters = array('a.product_id IN (' . implode(',', $cids) . ')');
     hikashop_addACLFilters($filters, 'product_access', 'a');
     $query = 'SELECT DISTINCT a.product_id, a.*,b.product_category_id, b.category_id, b.ordering FROM ' . hikashop_table('product') . ' AS a LEFT JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id = b.product_id WHERE ' . implode(' AND ', $filters) . ' ORDER BY b.ordering ASC, a.product_id ASC';
     $database = JFactory::getDBO();
     $database->setQuery($query);
     $elements = $database->loadObjectList();
     if (empty($elements)) {
         return;
     }
     $this->modules = $config->get('product_show_modules', '');
     $module = hikashop_get('helper.module');
     $this->modules = $module->setModuleData($this->modules);
     $currencyClass = hikashop_get('class.currency');
     $currency_id = hikashop_getCurrency();
     $zone_id = hikashop_getZone(null);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->selected_variant_id = 0;
     $productClass = hikashop_get('class.product');
     $this->assignRef('currencyHelper', $currencyClass);
     $fieldsClass = hikashop_get('class.field');
     $this->assignRef('fieldsClass', $fieldsClass);
     $classbadge = hikashop_get('class.badge');
     $this->assignRef('classbadge', $classbadge);
     $fields = array(0 => array());
     $unset = array();
     $done = array();
     foreach ($elements as $k => $element) {
         $product_id = $element->product_id;
         if (isset($done[$product_id])) {
             $unset[] = $k;
             continue;
         } else {
             $done[$product_id] = $product_id;
         }
         if ($element->product_type == 'variant') {
             $filters = array('a.product_id=' . $element->product_parent_id);
             hikashop_addACLFilters($filters, 'product_access', 'a');
             $query = 'SELECT a.*,b.* FROM ' . hikashop_table('product') . ' AS a LEFT JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id = b.product_id WHERE ' . implode(' AND ', $filters) . ' LIMIT 1';
             $database->setQuery($query);
             $elements[$k] = $database->loadObject();
             if (empty($elements[$k])) {
                 return;
             }
             $k = array_search($product_id, $cids);
             if ($k !== false) {
                 $cids[$k] = (int) $element->product_id;
             }
         }
         $productClass->addAlias($elements[$k]);
         if (!$elements[$k]->product_published) {
             return;
         }
         if ($compare_inc_lastseen) {
             $prod = new stdClass();
             $prod->product_id = $product_id;
             $prod->product_hit = $element->product_hit + 1;
             $prod->product_last_seen_date = time();
             $productClass->save($prod, true);
         }
         $f = $fieldsClass->getFields('frontcomp', $element, 'product', 'checkout&task=state');
         $fields[$element->product_id] =& $f;
         foreach ($f as $i => $v) {
             $fields[0][$i] = $v;
         }
     }
     if (!empty($unset)) {
         foreach ($unset as $u) {
             unset($elements[$u]);
         }
     }
     $query = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $cids) . ') AND file_type IN (\'product\',\'file\') ORDER BY file_ref_id ASC, file_ordering ASC, file_id ASC';
     $database->setQuery($query);
     $product_files = $database->loadObjectList();
     if (!empty($product_files)) {
         foreach ($elements as $k => $element) {
             $productClass->addFiles($elements[$k], $product_files);
         }
     }
     $defaultParams = $config->get('default_params');
     $detault_display_type = @$defaultParams['price_display_type'];
     $currencyClass->getListingPrices($elements, $zone_id, $currency_id, $detault_display_type);
     $this->assignRef('elements', $elements);
     $image = hikashop_get('helper.image');
     $this->assignRef('image', $image);
     $this->assignRef('fields', $fields);
     $url = $this->init();
     $cart->getJS($url);
     $this->assignRef('redirect_url', $url);
 }
コード例 #7
0
ファイル: canpar.php プロジェクト: rodhoff/MNW
 function onShippingDisplay(&$order, &$dbrates, &$usable_rates, &$messages)
 {
     if (!hikashop_loadUser()) {
         return false;
     }
     $local_usable_rates = array();
     $local_messages = array();
     $ret = parent::onShippingDisplay($order, $dbrates, $local_usable_rates, $local_messages);
     if ($ret === false) {
         return false;
     }
     $currentShippingZone = null;
     $currentCurrencyId = null;
     $found = true;
     $usableWarehouses = array();
     $zoneClass = hikashop_get('class.zone');
     $zones = $zoneClass->getOrderZones($order);
     foreach ($local_usable_rates as $k => $rate) {
         if (!empty($rate->shipping_params->warehousesList)) {
             $rate->shipping_params->warehouses = unserialize($rate->shipping_params->warehousesList);
         } else {
             $messages['no_warehouse_configured'] = 'No warehouse configured in the CANPAR shipping plugin options';
             continue;
         }
         foreach ($rate->shipping_params->warehouses as $warehouse) {
             if (empty($warehouse->zone) || $warehouse->zone == '-' || in_array($warehouse->zone, $zones)) {
                 $usableWarehouses[] = $warehouse;
             }
         }
         if (empty($usableWarehouses)) {
             $messages['no_warehouse_configured'] = 'No available warehouse found for your location';
             continue;
         }
         if (!empty($rate->shipping_params->methodsList)) {
             $rate->shipping_params->methods = unserialize($rate->shipping_params->methodsList);
         } else {
             $messages['no_shipping_methods_configured'] = 'No shipping methods configured in the CANPAR shipping plugin options';
             continue;
         }
         if ($order->weight <= 0 || $order->volume <= 0) {
             return true;
         }
         $data = null;
         if (empty($order->shipping_address)) {
             $messages['no_shipping_address_found'] = 'No shipping address entered';
             continue;
         }
         $this->shipping_currency_id = hikashop_getCurrency();
         $db = JFactory::getDBO();
         $query = 'SELECT currency_code FROM ' . hikashop_table('currency') . ' WHERE currency_id IN (' . $this->shipping_currency_id . ')';
         $db->setQuery($query);
         $this->shipping_currency_code = $db->loadResult();
         $cart = hikashop_get('class.cart');
         $null = null;
         $cart->loadAddress($null, $order->shipping_address->address_id, 'object', 'shipping');
         $currency = hikashop_get('class.currency');
         $receivedMethods = $this->_getBestMethods($rate, $order, $usableWarehouses, $null);
         if (empty($receivedMethods)) {
             $messages['no_rates'] = JText::_('NO_SHIPPING_METHOD_FOUND');
             continue;
         }
         $i = 0;
         $local_usable_rates = array();
         foreach ($receivedMethods as $method) {
             $local_usable_rates[$i] = !HIKASHOP_PHP5 ? $rate : clone $rate;
             $local_usable_rates[$i]->shipping_price += $method['value'];
             $selected_method = '';
             $name = '';
             foreach ($this->canpar_methods as $canpar_method) {
                 if ($canpar_method['name'] == $method['name']) {
                     $name = $canpar_method['name'];
                     $selected_method = $canpar_method['key'];
                 }
             }
             $local_usable_rates[$i]->shipping_name = $name;
             if (!empty($selected_method)) {
                 $local_usable_rates[$i]->shipping_id .= '-' . $selected_method;
             }
             if ($method['deliveryDate'] != 'www.canpar.ca') {
                 if (is_numeric($method['deliveryDate'])) {
                     $timestamp = strtotime($method['deliveryDate']);
                     $time = parent::displayDelaySECtoDAY($timestamp - strtotime('now'), 2);
                     $local_usable_rates[$i]->shipping_description .= 'Estimated delivery date:  ' . $time;
                 } else {
                     $time = $method['deliveryDate'];
                     $local_usable_rates[$i]->shipping_description .= 'Estimated delivery date:  ' . $time;
                 }
             } else {
                 $local_usable_rates[$i]->shipping_description .= ' ' . JText::_('NO_ESTIMATED_TIME_AFTER_SEND');
             }
             if ($rate->shipping_params->group_package == 1 && $this->nbpackage > 1) {
                 $local_usable_rates[$i]->shipping_description .= '<br/>' . JText::sprintf('X_PACKAGES', $this->nbpackage);
             }
             $i++;
         }
         foreach ($local_usable_rates as $i => $rate) {
             $usable_rates[$rate->shipping_id] = $rate;
         }
     }
 }
コード例 #8
0
ファイル: payment.php プロジェクト: rodhoff/MNW
 function &getPayments(&$order, $reset = false)
 {
     static $usable_methods = null;
     static $errors = array();
     if ($reset) {
         $usable_methods = null;
         $errors = array();
     }
     if (!is_null($usable_methods)) {
         $this->errors = $errors;
         return $usable_methods;
     }
     JPluginHelper::importPlugin('hikashoppayment');
     $dispatcher = JDispatcher::getInstance();
     $max = 0;
     $payment = '';
     if (!empty($order->payment->payment_type) && !empty($order->payment->payment_id)) {
         $payment = $order->payment->payment_type . '_' . $order->payment->payment_id;
     }
     $currency = @$order->total->prices[0]->price_currency_id;
     if (empty($currency)) {
         $currency = hikashop_getCurrency();
     }
     $methods = $this->getMethods($order, $currency);
     if (empty($methods)) {
         $errors[] = JText::_('CONFIGURE_YOUR_PAYMENT_METHODS');
         $this->errors = $errors;
         $usable_methods = false;
         return $usable_methods;
     }
     $already = array();
     $price_all = @$order->full_total->prices[0]->price_value_with_tax;
     if (isset($order->full_total->prices[0]->price_value_without_payment_with_tax)) {
         $price_all = $order->full_total->prices[0]->price_value_without_payment_with_tax;
     }
     $zoneClass = hikashop_get('class.zone');
     $zones = $zoneClass->getOrderZones($order);
     foreach ($methods as $k => $method) {
         if (!empty($method->payment_zone_namekey) && !in_array($method->payment_zone_namekey, $zones)) {
             unset($methods[$k]);
             continue;
         }
         if (!empty($method->payment_params->payment_zip_prefix) || !empty($method->payment_params->payment_min_zip) || !empty($method->payment_params->payment_max_zip) || !empty($method->payment_params->payment_zip_suffix)) {
             $checkDone = false;
             if (!empty($order->shipping_address) && !empty($order->shipping_address->address_post_code)) {
                 if (preg_match('#([a-z]*)([0-9]+)(.*)#i', preg_replace('#[^a-z0-9]#i', '', $order->shipping_address->address_post_code), $match)) {
                     $checkDone = true;
                     $prefix = $match[1];
                     $main = $match[2];
                     $suffix = $match[3];
                     if (!empty($method->payment_params->payment_zip_prefix) && $method->payment_params->payment_zip_prefix != $prefix) {
                         unset($methods[$k]);
                         continue;
                     }
                     if (!empty($method->payment_params->payment_min_zip) && $method->payment_params->payment_min_zip > $main) {
                         unset($methods[$k]);
                         continue;
                     }
                     if (!empty($method->payment_params->payment_max_zip) && $method->payment_params->payment_max_zip < $main) {
                         unset($methods[$k]);
                         continue;
                     }
                     if (!empty($method->payment_params->payment_zip_suffix) && $method->payment_params->payment_zip_suffix != $suffix) {
                         unset($methods[$k]);
                         continue;
                     }
                 }
             }
             if (!$checkDone) {
                 unset($methods[$k]);
                 continue;
             }
         }
         $currencyClass = hikashop_get('class.currency');
         $methods[$k]->payment_price = $currencyClass->round($price_all * (double) @$method->payment_params->payment_percentage / 100 + @$method->payment_price, $currencyClass->getRounding($currency, true));
         $methods[$k]->ordering = $method->payment_ordering;
         if (!empty($method->ordering) && $max < $method->ordering) {
             $max = $method->ordering;
         }
     }
     foreach ($methods as $k => $method) {
         if (empty($method->ordering)) {
             $max++;
             $methods[$k]->ordering = $max;
         }
         while (isset($already[$methods[$k]->ordering])) {
             $max++;
             $methods[$k]->ordering = $max;
         }
         $already[$methods[$k]->ordering] = true;
     }
     $cartClass = hikashop_get('class.cart');
     $paymentRecurringType = $cartClass->checkSubscription($order);
     $order->paymentOptions = array('recurring' => $paymentRecurringType == 'recurring', 'term' => false, 'recurring' => false);
     $this->checkPaymentOptions($order);
     $usable_methods = array();
     $dispatcher->trigger('onPaymentDisplay', array(&$order, &$methods, &$usable_methods));
     if (is_array($usable_methods) && !empty($usable_methods)) {
         foreach ($usable_methods as $k => $usable_method) {
             if ($paymentRecurringType == 'noRecurring' && (!empty($usable_method->features['recurring']) || isset($usable_method->recurring) && $usable_method->recurring == 1)) {
                 unset($usable_methods[$k]);
                 continue;
             }
             if ($paymentRecurringType == 'recurring' && empty($usable_method->features['recurring']) && (!isset($usable_method->recurring) || $usable_method->recurring != 1)) {
                 unset($usable_methods[$k]);
                 continue;
             }
             if (!empty($order->paymentOptions['term']) && empty($usable_method->features['authorize_capture'])) {
                 unset($usable_methods[$k]);
                 continue;
             }
             if (!empty($order->paymentOptions['refund']) && empty($usable_method->features['refund'])) {
                 unset($usable_methods[$k]);
                 continue;
             }
         }
     }
     if (empty($usable_methods)) {
         $errors[] = JText::_('NO_PAYMENT_METHODS_FOUND');
         $this->errors = $errors;
         $usable_methods = false;
         return $usable_methods;
     }
     ksort($usable_methods);
     $this->errors = $errors;
     return $usable_methods;
 }
コード例 #9
0
ファイル: view.html.php プロジェクト: q0821/esportshop
 function listing()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config =& hikashop_config();
     $this->assignRef('config', $config);
     $toggle = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggle);
     $manage = hikashop_isAllowed($config->get('acl_user_manage', 'all'));
     $this->assignRef('manage', $manage);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $cfg = array('table' => 'user', 'main_key' => 'user_id', 'order_sql_value' => 'huser.user_id', 'order_sql_accept' => array('huser.', 'juser.'));
     $searchMap = array('huser.user_id', 'huser.user_email', 'juser.username', 'juser.email', 'juser.name');
     $pageInfo = $this->getPageInfo($cfg['order_sql_value']);
     $pageInfo->filter->filter_partner = $app->getUserStateFromRequest($this->paramBase . '.filter_partner', 'filter_partner', '', 'int');
     $filters = array();
     $order = '';
     if (!empty($pageInfo->filter->filter_partner)) {
         if ($pageInfo->filter->filter_partner == 1) {
             $filters[] = 'huser.user_partner_activated = 1';
             $db->setQuery('DROP TABLE IF EXISTS ' . hikashop_table('click_view') . ', ' . hikashop_table('sale_view') . ', ' . hikashop_table('lead_view'));
             $db->query();
             $query = 'CREATE OR REPLACE VIEW ' . hikashop_table('click_view') . ' AS SELECT a.user_id, SUM(b.click_partner_price) AS click_price FROM ' . hikashop_table('user') . ' AS a LEFT JOIN ' . hikashop_table('click') . ' AS b ON a.user_id=b.click_partner_id AND (CASE WHEN a.user_currency_id=0 THEN ' . hikashop_getCurrency() . ' ELSE a.user_currency_id END)=b.click_partner_currency_id WHERE a.user_partner_activated=1 AND b.click_partner_paid=0 GROUP BY b.click_partner_id;';
             $db->setQuery($query);
             $db->query();
             $partner_valid_status_list = explode(',', $config->get('partner_valid_status', 'confirmed,shipped'));
             foreach ($partner_valid_status_list as $k => $partner_valid_status) {
                 $partner_valid_status_list[$k] = $db->Quote($partner_valid_status);
             }
             $query = 'CREATE OR REPLACE VIEW ' . hikashop_table('sale_view') . ' AS SELECT a.user_id, SUM(b.order_partner_price) AS sale_price FROM ' . hikashop_table('user') . ' AS a LEFT JOIN ' . hikashop_table('order') . ' AS b ON a.user_id=b.order_partner_id AND (CASE WHEN a.user_currency_id=0 THEN ' . hikashop_getCurrency() . ' ELSE a.user_currency_id END)=b.order_partner_currency_id WHERE a.user_partner_activated=1 AND b.order_partner_paid=0 AND b.order_type=\'sale\' AND b.order_status IN (' . implode(',', $partner_valid_status_list) . ') GROUP BY b.order_partner_id;';
             $db->setQuery($query);
             $db->query();
             $query = 'CREATE OR REPLACE VIEW ' . hikashop_table('lead_view') . ' AS SELECT a.user_id, SUM(b.user_partner_price) AS lead_price FROM ' . hikashop_table('user') . ' AS a LEFT JOIN ' . hikashop_table('user') . ' AS b ON a.user_id=b.user_partner_id AND (CASE WHEN a.user_currency_id=0 THEN ' . hikashop_getCurrency() . ' ELSE a.user_currency_id END)=b.user_partner_currency_id WHERE a.user_partner_activated=1 AND b.user_partner_paid=0 GROUP BY b.user_partner_id;';
             $db->setQuery($query);
             $db->query();
             $db->setQuery('UPDATE ' . hikashop_table('user') . ' SET user_unpaid_amount=0');
             $db->query();
             $query = 'UPDATE ' . hikashop_table('user') . ' AS a JOIN ' . hikashop_table('click_view') . ' AS b ON a.user_id=b.user_id SET a.user_unpaid_amount=b.click_price WHERE a.user_partner_activated=1';
             $db->setQuery($query);
             $db->query();
             $query = 'UPDATE ' . hikashop_table('user') . ' AS a JOIN ' . hikashop_table('sale_view') . ' AS b ON a.user_id=b.user_id SET a.user_unpaid_amount=a.user_unpaid_amount+b.sale_price WHERE a.user_partner_activated=1';
             $db->setQuery($query);
             $db->query();
             $query = 'UPDATE ' . hikashop_table('user') . ' AS a JOIN ' . hikashop_table('lead_view') . ' AS b ON a.user_id=b.user_id SET a.user_unpaid_amount=a.user_unpaid_amount+b.lead_price WHERE a.user_partner_activated=1';
             $db->setQuery($query);
             $db->query();
             $db->setQuery('DROP VIEW IF EXISTS ' . hikashop_table('click_view') . ', ' . hikashop_table('sale_view') . ', ' . hikashop_table('lead_view'));
             $db->query();
             $currencyClass = hikashop_get('class.currency');
             $this->assignRef('currencyHelper', $currencyClass);
         } else {
             $filters[] = 'huser.user_partner_activated=0';
         }
     }
     $fieldsClass = hikashop_get('class.field');
     $this->assignRef('fieldsClass', $fieldsClass);
     $fields = $fieldsClass->getData('backend_listing', 'user', false);
     $this->assignRef('fields', $fields);
     foreach ($fields as $field) {
         $searchMap[] = 'huser.' . $field->field_namekey;
     }
     $this->processFilters($filters, $order, $searchMap, $cfg['order_sql_accept']);
     $query = ' FROM ' . hikashop_table($cfg['table']) . ' AS huser LEFT JOIN ' . hikashop_table('users', false) . ' AS juser ON huser.user_cms_id = juser.id ' . $filters . $order;
     $db->setQuery('SELECT huser.*, juser.* ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
     $rows = $db->loadObjectList();
     $fieldsClass->handleZoneListing($fields, $rows);
     foreach ($rows as $k => $row) {
         if (!empty($row->user_params)) {
             $rows[$k]->user_params = unserialize($row->user_params);
         }
     }
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, $cfg['main_key']);
     }
     $this->assignRef('rows', $rows);
     $db->setQuery('SELECT COUNT(*) ' . $query);
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = $db->loadResult();
     $pageInfo->elements->page = count($rows);
     $this->getPagination();
     $this->getOrdering('huser.user_id', true);
     $partner = hikashop_get('type.user_partner');
     $this->assignRef('partner', $partner);
     $affiliate_plugin = JPluginHelper::getPlugin('system', 'hikashopaffiliate');
     $affiliate_active = !empty($affiliate_plugin);
     $this->assignRef('affiliate_active', $affiliate_active);
     if ($pageInfo->filter->filter_partner == 1) {
         $acl = 'acl_affiliates_delete';
     } else {
         $acl = 'acl_user_delete';
     }
     $this->toolbar = array(array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'check' => JText::_('HIKA_VALIDDELETEITEMS'), 'display' => hikashop_isAllowed($config->get($acl, 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     return true;
 }
コード例 #10
0
ファイル: hikashop.php プロジェクト: q0821/esportshop
    function generateCoupon(&$allresults, $i, &$user)
    {
        list($minimum_order, $quota, $start, $end, $percent_amount, $flat_amount, $currency_id, $code, $product_id) = explode('|', $allresults[1][$i]);
        jimport('joomla.user.helper');
        $key = JUserHelper::genrandompassword(5);
        if (!hikashop_level(1)) {
            $minimum_order = 0;
            $quota = '';
            $product_id = '';
        }
        if ($percent_amount > 0) {
            $value = $percent_amount;
        } else {
            $value = $flat_amount;
        }
        $value = str_replace(',', '.', $value);
        if ($start) {
            $start = hikashop_getTime($start);
        }
        if ($end) {
            $end = hikashop_getTime($end);
        }
        $clean_name = strtoupper($user->name);
        $space = strpos($clean_name, ' ');
        if (!empty($space)) {
            $clean_name = substr($clean_name, 0, $space);
        }
        $code = str_replace(array('[name]', '[clean_name]', '[subid]', '[email]', '[key]', '[flat]', '[percent]', '[value]', '[prodid]'), array($user->name, $clean_name, $user->subid, $user->email, $key, $flat_amount, $percent_amount, $value, $product_id), $code);
        $this->db->setQuery('INSERT IGNORE INTO ' . acymailing_table('hikashop_discount', false) . '(
		`discount_code`,
		`discount_percent_amount`,
		`discount_flat_amount`,
		`discount_type`,
		`discount_start`,
		`discount_end`,
		`discount_minimum_order`,
		`discount_quota`,
		`discount_currency_id`,
		`discount_product_id`,
		`discount_published`
		) VALUES (' . $this->db->Quote($code) . ',' . $this->db->Quote($percent_amount) . ',' . $this->db->Quote($flat_amount) . ',\'coupon\',' . $this->db->Quote($start) . ',' . $this->db->Quote($end) . ',' . $this->db->Quote($minimum_order) . ',' . $this->db->Quote($quota) . ',' . $this->db->Quote(hikashop_getCurrency()) . ',' . $this->db->Quote($product_id) . ',
		1)');
        $this->db->query();
        return $code;
    }
コード例 #11
0
ファイル: checkout.php プロジェクト: q0821/esportshop
 function _readPayment()
 {
     $payment = JRequest::getString('hikashop_payment', '');
     if (empty($payment)) {
         return false;
     }
     $payment = explode('_', $payment);
     if (count($payment) > 1) {
         $payment_id = array_pop($payment);
         $payment = implode('_', $payment);
         if (empty($payment)) {
             return false;
         }
         $cart = $this->initCart();
         $pluginsClass = hikashop_get('class.plugins');
         $rates = $pluginsClass->getMethods('payment');
         $data = hikashop_import('hikashoppayment', $payment);
         $paymentData = $data->onPaymentSave($cart, $rates, $payment_id);
         if ($paymentData === false) {
             return false;
         }
         $app = JFactory::getApplication();
         $old_payment_method = $app->getUserState(HIKASHOP_COMPONENT . '.payment_method');
         $old_payment_data = $app->getUserState(HIKASHOP_COMPONENT . '.payment_data');
         $old_payment_id = $app->getUserState(HIKASHOP_COMPONENT . '.payment_id');
         $app->setUserState(HIKASHOP_COMPONENT . '.payment_method', $payment);
         $app->setUserState(HIKASHOP_COMPONENT . '.payment_id', $payment_id);
         $price_all = @$cart->full_total->prices[0]->price_value_with_tax;
         if (isset($cart->full_total->prices[0]->price_value_without_payment_with_tax)) {
             $price_all = @$cart->full_total->prices[0]->price_value_without_payment_with_tax;
         }
         $currencyClass = hikashop_get('class.currency');
         $currencyClass->convertPayments($rates);
         $paymentClass = hikashop_get('class.payment');
         $paymentClass->computePrice($cart, $paymentData, $price_all, $paymentData->payment_price, hikashop_getCurrency());
         $cart->full_total->prices[0]->payment_tax = @$paymentData->payment_tax;
         $app->setUserState(HIKASHOP_COMPONENT . '.payment_data', $paymentData);
         if (!empty($paymentData->ask_cc)) {
             $paymentClass = hikashop_get('class.payment');
             if (!$paymentClass->readCC()) {
                 return false;
             }
         }
         if ($old_payment_id != $payment_id || $old_payment_method != $payment || @$old_payment_data->payment_price != $paymentData->payment_price && ($this->_getStep('cart', (int) $this->previous) === (int) $this->previous || $this->_getStep('confirm', (int) $this->previous) === (int) $this->previous)) {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #12
0
ファイル: hikashopproductinsert.php プロジェクト: rodhoff/MNW
 function onAfterRender()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return true;
     }
     $layout = JRequest::getString('layout');
     if ($layout == 'edit') {
         return true;
     }
     $body = JResponse::getBody();
     $alternate_body = false;
     if (empty($body)) {
         $body = $app->getBody();
         $alternate_body = true;
     }
     $search_space = substr($body, strpos($body, '<body'));
     if (!(preg_match_all('#\\{product\\}(.*)\\{\\/product\\}#Uis', $search_space, $matches) || preg_match_all('#\\{product (.*)\\}#Uis', $search_space, $matches))) {
         return;
     }
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return true;
     }
     $db = JFactory::getDBO();
     $currencyClass = hikashop_get('class.currency');
     $this->image = hikashop_get('helper.image');
     $this->classbadge = hikashop_get('class.badge');
     $para = array();
     $nbtag = count($matches[1]);
     for ($i = 0; $i < $nbtag; $i++) {
         $para[$i] = explode('|', $matches[1][$i]);
     }
     $k = 0;
     $ids = array();
     for ($i = 0; $i < $nbtag; $i++) {
         for ($u = 0; $u < count($para[$i]); $u++) {
             if (in_array($para[$i][$u], array('name', 'pricetax', 'pricedis', 'cart', 'quantityfield', 'description', 'link', 'border', 'badge', 'picture'))) {
                 continue;
             }
             $ids[$k] = (int) $para[$i][$u];
             $k++;
         }
     }
     $product_query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $ids) . ') AND product_access=\'all\' AND product_published=1 AND product_type=\'main\'';
     $db->setQuery($product_query);
     $products = $db->loadObjectList();
     $db->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' WHERE variant_product_id IN (' . implode(',', $ids) . ')');
     $variants = $db->loadObjectList();
     if (!empty($variants)) {
         foreach ($products as $k => $product) {
             foreach ($variants as $variant) {
                 if ($product->product_id == $variant->variant_product_id) {
                     $products[$k]->has_options = true;
                     break;
                 }
             }
         }
     }
     $db->setQuery('SELECT product_id FROM ' . hikashop_table('product_related') . ' WHERE product_related_type = ' . $db->quote('options') . ' AND product_id IN (' . implode(',', $ids) . ')');
     $options = $db->loadObjectList();
     if (!empty($options)) {
         foreach ($products as $k => $product) {
             foreach ($options as $option) {
                 if ($product->product_id == $option->product_id) {
                     $products[$k]->has_options = true;
                     break;
                 }
             }
         }
     }
     foreach ($products as $k => $product) {
         $this->classbadge->loadBadges($products[$k]);
     }
     $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ordering ASC, file_id ASC';
     $db->setQuery($queryImage);
     $images = $db->loadObjectList();
     $productClass = hikashop_get('class.product');
     foreach ($products as $k => $row) {
         $productClass->addAlias($products[$k]);
         foreach ($images as $j => $image) {
             if ($row->product_id != $image->file_ref_id) {
                 continue;
             }
             foreach (get_object_vars($image) as $key => $name) {
                 if (!isset($products[$k]->images)) {
                     $products[$k]->images = array();
                 }
                 if (!isset($products[$k]->images[$j])) {
                     $products[$k]->images[$j] = new stdClass();
                 }
                 $products[$k]->images[$j]->{$key} = $name;
             }
         }
     }
     $zone_id = hikashop_getZone();
     $currencyClass = hikashop_get('class.currency');
     $config = hikashop_config();
     $defaultParams = $config->get('default_params');
     $currencyClass->getListingPrices($products, $zone_id, hikashop_getCurrency(), $defaultParams['price_display_type']);
     $fields = array('name' => 'name', 'pricedis1' => 'pricedis', 'pricedis2' => array('pricedis', 2), 'pricedis3' => array('pricedis', 3), 'pricetax1' => 'pricetax', 'pricetax2' => array('pricetax', 2), 'price' => 'price', 'cart' => 'cart', 'quantityfield' => 'quantityfield', 'description' => 'description', 'picture' => 'picture', 'link' => 'link', 'border' => 'border', 'badge' => 'badge');
     for ($i = 0; $i < $nbtag; $i++) {
         $nbprodtag = count($para[$i]);
         foreach ($fields as $k => $v) {
             if (is_string($v)) {
                 $this->{$v} = 0;
             }
             if (in_array($k, $para[$i])) {
                 if (is_array($v)) {
                     $this->{$v[0]} = $v[1];
                 } else {
                     $this->{$v} = 1;
                 }
                 $nbprodtag--;
             }
         }
         $this->menuid = 0;
         foreach ($para[$i] as $key => $value) {
             if (substr($value, 0, 6) == "menuid") {
                 $explode = explode(':', $value);
                 $this->menuid = $explode[1];
             }
         }
         $id = array();
         for ($j = 0; $j < $nbprodtag; $j++) {
             $id[$j] = $para[$i][$j];
         }
         $name = 'hikashopproductinsert_view.php';
         $path = JPATH_THEMES . DS . $app->getTemplate() . DS . 'system' . DS . $name;
         if (!file_exists($path)) {
             if (version_compare(JVERSION, '1.6', '<')) {
                 $path = JPATH_PLUGINS . DS . 'system' . DS . $name;
             } else {
                 $path = JPATH_PLUGINS . DS . 'system' . DS . 'hikashopproductinsert' . DS . $name;
             }
             if (!file_exists($path)) {
                 return true;
             }
         }
         ob_start();
         require $path;
         $product_view = ob_get_clean();
         $pattern = '#\\{product\\}(.*)\\{\\/product\\}#Uis';
         $replacement = '';
         $body = JResponse::getBody();
         $alternate_body = false;
         if (empty($body)) {
             $body = $app->getBody();
             $alternate_body = true;
         }
         $search_space = substr($body, strpos($body, '<body'));
         $new_search_space = preg_replace($pattern, str_replace('$', '\\$', $product_view), $search_space, 1);
         $pattern = '#\\{product (.*)\\}#Uis';
         $replacement = '';
         $new_search_space = preg_replace($pattern, str_replace('$', '\\$', $product_view), $new_search_space, 1);
         $body = str_replace($search_space, $new_search_space, $body);
         if ($alternate_body) {
             $app->setBody($body);
         } else {
             JResponse::setBody($body);
         }
     }
 }
コード例 #13
0
ファイル: userpoints.php プロジェクト: q0821/esportshop
 function onCheckoutStepDisplay($layoutName, &$html, &$view)
 {
     if ($layoutName != 'plg.shop.userpoints') {
         return;
     }
     $this->_readOptions();
     if (empty($this->plugin_options['checkout_step'])) {
         return;
     }
     switch ($this->plugin_options['show_points']) {
         case 'aup':
             $points = $this->getUserPoints(null, 'aup');
             break;
         case 'hk':
         default:
             $points = $this->getUserPoints(null, 'hk');
             break;
     }
     if ($points === false) {
         return;
     }
     if (!empty($this->plugin_options['hide_when_no_points']) && empty($points)) {
         return;
     }
     $app = JFactory::getApplication();
     $currencyClass = hikashop_get('class.currency');
     $consume = null;
     $discount = '';
     $earn_points = false;
     $use_coupon = 1 - (int) $app->getUserState(HIKASHOP_COMPONENT . '.userpoints_no_virtual_coupon', (int) (@$this->plugin_options['checkout_step'] && @$this->plugin_options['default_no_use']));
     $paymentUserPoints = hikashop_import('hikashoppayment', 'userpoints');
     if (!empty($paymentUserPoints)) {
         $cart = $view->initCart();
         $consume = $paymentUserPoints->getCartUsedPoints($cart);
         if (!empty($consume) && $consume['mode'] != $this->plugin_options['show_points']) {
             $consume = null;
         }
         if (!empty($this->plugin_options['show_earn_points'])) {
             $earn_points = 0;
             $this->onGetUserPointsEarned($cart, $earn_points, $this->plugin_options['show_points']);
         }
         if (!empty($consume)) {
             if (isset($cart->order_currency_id)) {
                 $currency_id = $cart->order_currency_id;
             } else {
                 $currency_id = hikashop_getCurrency();
             }
             $discount = $currencyClass->format($consume['value'], $currency_id);
         }
     }
     $app = JFactory::getApplication();
     $path = JPATH_THEMES . DS . $app->getTemplate() . DS . 'plg_hikashop_userpoints' . DS . 'checkout.php';
     if (!file_exists($path)) {
         if (version_compare(JVERSION, '1.6', '<')) {
             $path = JPATH_PLUGINS . DS . 'hikashop' . DS . 'userpoints_checkout.php';
         } else {
             $path = JPATH_PLUGINS . DS . 'hikashop' . DS . 'userpoints' . DS . 'userpoints_checkout.php';
         }
     }
     if (!file_exists($path)) {
         return false;
     }
     require $path;
 }
コード例 #14
0
ファイル: view.html.php プロジェクト: q0821/esportshop
 function showcarts()
 {
     $app = JFactory::getApplication();
     $config = hikashop_config();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     global $Itemid;
     if (empty($menu)) {
         if (!empty($Itemid)) {
             $menus->setActive($Itemid);
             $menu = $menus->getItem($Itemid);
         }
     }
     if (is_object($menu) && is_object($menu->params)) {
         $cart_type = $menu->params->get('cart_type');
     }
     if (!empty($cart_type)) {
         JRequest::setVar('cart_type', $cart_type);
     } else {
         $cart_type = JRequest::getString('cart_type', 'cart');
         if (!in_array($cart_type, array('cart', 'wishlist'))) {
             $cart_type = 'cart';
         }
     }
     $this->assignRef('cart_type', $cart_type);
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.cart_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->search = JString::strtolower(trim($pageInfo->search));
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $oldValue = $app->getUserState($this->paramBase . '.list_limit');
     if (empty($oldValue)) {
         $oldValue = $app->getCfg('list_limit');
     }
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if ($oldValue != $pageInfo->limit->value) {
         $pageInfo->limit->start = 0;
         $app->setUserState($this->paramBase . '.limitstart', 0);
     }
     $database = JFactory::getDBO();
     $searchMap = array('a.cart_id', 'a.cart_name', 'a.cart_type');
     if (hikashop_loadUser() == null) {
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (!HIKASHOP_J16) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         if ($config->get('enable_multicart', '0')) {
             $app->redirect(JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))), false));
         } else {
             $app->redirect(JRoute::_($url . '&return=' . base64_encode(hikashop_completeLink('cart&task=showcart&cart_type=' . $cart_type . '&Itemid=' . $Itemid, false, false, true)), false));
         }
         return false;
     }
     $user = hikashop_loadUser(true);
     if (isset($user->user_cms_id)) {
         $user->id = $user->user_cms_id;
     } else {
         if (empty($user)) {
             $user = new stdClass();
         }
         $user->id = 0;
     }
     $session = JFactory::getSession();
     if ($session->getId()) {
         $user->session = $session->getId();
     } else {
         $user->session = '';
     }
     if (hikashop_loadUser() == null) {
         $filters = array('a.session_id=' . $database->Quote($user->session) . ' AND a.cart_type =' . $database->quote($cart_type));
     } else {
         $filters = array('(a.user_id=' . (int) $user->id . ' OR a.session_id=' . $database->Quote($user->session) . ') AND a.cart_type =' . $database->quote($cart_type));
     }
     $groupBy = 'GROUP BY a.cart_id';
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = 'ORDER BY a.cart_id ASC';
     }
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\'';
         $filter = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
         $filters[] = $filter;
     }
     $from = 'FROM ' . hikashop_table('cart') . ' AS a';
     $cartProduct = 'LEFT JOIN ' . hikashop_table('cart_product') . ' AS b ON a.cart_id=b.cart_id';
     $where = 'WHERE (' . implode(') AND (', $filters) . ') AND a.cart_type =' . $database->quote($cart_type);
     $query = $from . ' ' . $where . ' ' . $groupBy . ' ' . $order;
     //'.$cartProduct.'
     $database->setQuery('SELECT a.* ' . $query);
     $rows = $database->loadObjectList();
     $database->setQuery('SELECT COUNT(*) ' . $from . ' ' . $where);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyClass);
     $module = hikashop_get('helper.module');
     $module->initialize($this);
     $currencyClass = hikashop_get('class.currency');
     $class = hikashop_get('class.cart');
     $productClass = hikashop_get('class.product');
     $main_currency = (int) $config->get('main_currency', 1);
     $currency_id = hikashop_getCurrency();
     if ($config->get('tax_zone_type', 'shipping') == 'billing') {
         $zone_id = hikashop_getZone('billing');
     } else {
         $zone_id = hikashop_getZone('shipping');
     }
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $cids = array();
     foreach ($rows as $row) {
         if ($row->cart_id != null) {
             $cids[] = $row->cart_id;
         }
     }
     $filters = '';
     $filters = array('a.cart_id IN(' . implode(",", $cids) . ')');
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY cart_id ASC';
     }
     $product = ' LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id';
     $query = 'FROM ' . hikashop_table('cart_product') . ' AS a ' . $product . ' WHERE (' . implode(') AND (', $filters) . ') ' . $order;
     $database->setQuery('SELECT a.*,b.* ' . $query);
     if (!empty($cids)) {
         $products = $database->loadObjectList();
         $ids = array();
         foreach ($products as $row) {
             $ids[] = $row->product_id;
         }
         $row_1 = 0;
         foreach ($products as $k => $row) {
             $currencyClass->getPrices($row, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax);
             if (!isset($row->prices[0]->price_value)) {
                 if (isset($row_1->prices[0])) {
                     $row->prices[0] = $row_1->prices[0];
                 }
             }
             $products[$k]->hide = 0;
             if ($row->product_type == 'variant') {
                 $l = --$k;
                 if (isset($products[$l])) {
                     if (!isset($products[$l]) || !is_object($products[$l])) {
                         $products[$l] = new stdClass();
                     }
                     $products[$l]->hide = 1;
                 }
             }
             $row_1 = $row;
         }
         $currentId = 0;
         $values = null;
         $price = 0;
         $price_with_tax = 0;
         $quantity = 0;
         $currency = hikashop_getCurrency();
         foreach ($products as $product) {
             if (isset($product->cart_id) && isset($product->product_id)) {
                 if ($product->cart_id != $currentId) {
                     $price = 0;
                     $price_with_tax = 0;
                     $quantity = 0;
                     $currentId = $product->cart_id;
                     if (isset($product->prices[0]->price_currency_id)) {
                         $currency = $product->prices[0]->price_currency_id;
                     }
                 }
                 if (isset($product->prices[0])) {
                     $price += $product->cart_product_quantity * $product->prices[0]->price_value;
                 }
                 if (isset($product->prices[0]->price_value_with_tax)) {
                     $price_with_tax += $product->cart_product_quantity * $product->prices[0]->price_value_with_tax;
                 }
                 if (!isset($product->prices[0]->price_value)) {
                     $variant = new stdClass();
                     $variant->product_parent_id = $product->product_parent_id;
                     $variant->quantity = $product->cart_product_quantity;
                 }
                 if (isset($variant) && isset($product->prices[0]) && $product->product_id == $variant->product_parent_id) {
                     $price += $variant->quantity * $product->prices[0]->price_value;
                     $price_with_tax += $variant->quantity * $product->prices[0]->price_value_with_tax;
                 }
                 $quantity += $product->cart_product_quantity;
                 if (!isset($values[$currentId])) {
                     $values[$currentId] = new stdClass();
                 }
                 $values[$currentId]->price = $price;
                 $values[$currentId]->price_with_tax = isset($price_with_tax) ? $price_with_tax : $price;
                 $values[$currentId]->quantity = $quantity;
                 $values[$currentId]->currency = $currency;
             }
         }
         $totalCart = 0;
         $limit = 0;
         foreach ($rows as $k => $row) {
             if ($limit >= (int) $pageInfo->limit->start && $limit < (int) $pageInfo->limit->value && isset($values[$row->cart_id]) && $values[$row->cart_id] != null) {
                 $rows[$k]->price = $values[$row->cart_id]->price;
                 $rows[$k]->price_with_tax = $values[$row->cart_id]->price_with_tax;
                 $rows[$k]->quantity = $values[$row->cart_id]->quantity;
                 $rows[$k]->currency = $values[$row->cart_id]->currency;
                 $totalCart++;
             } else {
                 unset($rows[$k]);
                 $limit--;
             }
             $limit++;
         }
     }
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = count($rows);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'cart_id');
     }
     $pageInfo->elements->page = count($rows);
     if (!$pageInfo->elements->page) {
         if (hikashop_loadUser() != null) {
             $app = JFactory::getApplication();
             if ($cart_type == 'cart') {
                 $app->enqueueMessage(JText::_('HIKA_NO_CARTS_FOUND'));
             } else {
                 $app->enqueueMessage(JText::_('HIKA_NO_WISHLISTS_FOUND'));
             }
         }
     }
     jimport('joomla.html.pagination');
     $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $pagination->hikaSuffix = '';
     $this->assignRef('pagination', $pagination);
     $this->assignRef('pageInfo', $pageInfo);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->assignRef('config', $config);
     $this->assignRef('carts', $rows);
     if ($cart_type == 'cart') {
         $title = JText::_('CARTS');
     } else {
         $title = JText::_('WISHLISTS');
     }
     hikashop_setPageTitle($title);
 }
コード例 #15
0
 /**
  *
  */
 function onShippingDisplay(&$order, &$dbrates, &$usable_rates, &$messages)
 {
     if (!hikashop_loadUser()) {
         return false;
     }
     if (empty($order->shipping_address)) {
         return true;
     }
     if ($this->loadShippingCache($order, $usable_rates, $messages)) {
         return true;
     }
     $local_usable_rates = array();
     $local_messages = array();
     $ret = parent::onShippingDisplay($order, $dbrates, $local_usable_rates, $local_messages);
     if ($ret === false) {
         return false;
     }
     $currentShippingZone = null;
     $currentCurrencyId = null;
     $cache_usable_rates = array();
     $cache_messages = array();
     $found = true;
     $usableWarehouses = array();
     $zoneClass = hikashop_get('class.zone');
     $zones = $zoneClass->getOrderZones($order);
     if (!function_exists('curl_init')) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('The Envoimoinscher shipping plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error');
         return false;
     }
     $app = JFactory::getApplication();
     $order_clone = new stdClass();
     $variables = array('products', 'cart_id', 'coupon', 'shipping_address', 'volume', 'weight', 'volume_unit', 'weight_unit');
     foreach ($variables as $var) {
         if (isset($order->{$var})) {
             $order_clone->{$var} = $order->{$var};
         }
     }
     $shipping_key = sha1(serialize($order_clone) . serialize($local_usable_rates));
     $result = $app->getUserState(HIKASHOP_COMPONENT . '.shipping.envoimoinscher_result', $this->result);
     // when cache doesn't work we generate a key in order not to redo everything at each step
     if (isset($result['shipping_key']) && $result['shipping_key'] == $shipping_key) {
         return;
     }
     if (empty($order->shipping_address)) {
         return true;
     }
     foreach ($local_usable_rates as $k => $rate) {
         if (!empty($rate->shipping_params->methodsList)) {
             $rate->shipping_params->methods = unserialize($rate->shipping_params->methodsList);
         } else {
             $cache_messages['no_shipping_methods_configured'] = 'No shipping methods selected in the Envoimoinscher shipping plugin options';
             continue;
         }
         if ($order->weight <= 0 || $order->volume <= 0 && @$rate->shipping_params->exclude_dimensions != 1) {
             continue;
         }
         $currencyClass = hikashop_get('class.currency');
         $this->shipping_currency_id = hikashop_getCurrency();
         $currency = $currencyClass->get($this->shipping_currency_id);
         $this->shipping_currency_code = $currency->currency_code;
         $cart = hikashop_get('class.cart');
         $null = null;
         $cart->loadAddress($null, $order->shipping_address->address_id, 'object', 'shipping');
         $sending_type = strtolower($rate->shipping_params->sending_type);
         // Get all data for send requests to envoimoinscher
         $this->getData($null, $rate, $order, $sending_type, false);
         if (empty($this->result)) {
             $cache_messages['no_rates'] = JText::_('NO_SHIPPING_METHOD_FOUND');
             continue;
         }
         $new_usable_rates = array();
         foreach ($this->result as $key => $method) {
             if ($key === "shipping_key") {
                 continue;
             }
             $o = !HIKASHOP_PHP5 ? $rate : clone $rate;
             $o->shipping_price = $method["Prix"];
             $selected_method = '';
             $name = '';
             $selected_method = $method['Transporteur'];
             $name = $method['Service'];
             $o->shipping_name = $selected_method . " / " . $name;
             if (!empty($selected_method)) {
                 $o->shipping_id .= '-' . $selected_method . " / " . $name;
             }
             $new_usable_rates[] = $o;
         }
         foreach ($new_usable_rates as $i => $rate) {
             $usable_rates[$rate->shipping_id] = $rate;
             $cache_usable_rates[$rate->shipping_id] = $rate;
         }
         $this->result = array();
     }
     $this->setShippingCache($order, $cache_usable_rates, $cache_messages);
     if (!empty($cache_messages)) {
         foreach ($cache_messages as $k => $msg) {
             $messages[$k] = $msg;
         }
     }
 }
コード例 #16
0
ファイル: option_price.php プロジェクト: jhener79/vlakc
<?php

/**
 * @package	HikaShop for Joomla!
 * @version	2.3.5
 * @author	hikashop.com
 * @copyright	(C) 2010-2015 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
if (!headers_sent()) {
    header('Content-Type: text/css; charset=utf-8');
}
$price = JRequest::getVar('price', 0);
$currency = hikashop_get('class.currency');
echo '<span class="hikashop_option_price_title">' . JText::_('PRICE_WITH_OPTIONS') . ':</span> <span class="hikashop_option_price_value">' . $currency->format($price, hikashop_getCurrency()) . '</span>';
exit;
コード例 #17
0
ファイル: massaction_product.php プロジェクト: rodhoff/MNW
 function onProcessProductMassActionupdateValues(&$elements, &$action, $k)
 {
     $current = 'product';
     $current_id = $current . '_id';
     $ids = array();
     foreach ($elements as $element) {
         $ids[] = $element->{$current_id};
         if (isset($element->{$action}['type'])) {
             $element->{$action}['type'] = $action['value'];
         }
     }
     $action['type'] = strip_tags($action['type']);
     $alias = explode('_', $action['type']);
     $queryTables = array($current);
     $possibleTables = array($current, 'price');
     $value = $this->massaction->updateValuesSecure($action, $possibleTables, $queryTables);
     if (!empty($queryTables)) {
         $query = 'UPDATE ' . hikashop_table($current) . ' AS hk_' . $current . ' ';
         $queryTables = array_unique($queryTables);
         foreach ($queryTables as $queryTable) {
             switch ($queryTable) {
                 case 'price':
                 case 'hk_price':
                     $query .= 'LEFT JOIN ' . hikashop_table('price') . ' AS hk_price ON hk_price.price_product_id = hk_product.product_id ';
                     break;
             }
         }
         if (!in_array($alias[0], array('product', 'price'))) {
             $hk = 'product';
         } else {
             $hk = $alias[0];
         }
         $db = JFactory::getDBO();
         JArrayHelper::toInteger($ids);
         $max = 500;
         if (count($ids) > $max) {
             $c = ceil((int) count($ids) / $max);
             $mainQuery = $query;
             for ($i = 0; $i < $c; $i++) {
                 $offset = $max * $i;
                 $id = array_slice($ids, $offset, $max);
                 $query = $mainQuery . ' SET hk_' . $hk . '.' . $action['type'] . ' = ' . $value . ' ';
                 $query .= 'WHERE hk_' . $current . '.' . $current . '_id IN (' . implode(',', $id) . ')';
                 $db->setQuery($query);
                 $db->query();
             }
         } else {
             $query .= 'SET hk_' . $hk . '.' . $action['type'] . ' = ' . $value . ' ';
             $query .= 'WHERE hk_' . $current . '.' . $current . '_id IN (' . implode(',', $ids) . ')';
             $db->setQuery($query);
             $db->query();
         }
         if ($hk == 'price') {
             $db->setQuery('SELECT price_product_id FROM ' . hikashop_table('price') . ' WHERE `price_product_id` IN (' . implode(',', $ids) . ')');
             $existingIds = $db->loadObjectList();
             foreach ($existingIds as $k => $existingId) {
                 $existingIds[$k] = $existingId->price_product_id;
             }
             if (count($existingIds) < count($ids)) {
                 if (!is_array($existingIds)) {
                     $existingIds = array($existingIds);
                 }
                 $missingInsert = array_diff($ids, $existingIds);
                 if (!empty($missingInsert)) {
                     $values = array();
                     foreach ($missingInsert as $id) {
                         $data = new stdClass();
                         $data->price_currency_id = hikashop_getCurrency();
                         $data->price_product_id = $id;
                         $data->price_value = 0;
                         $data->price_min_quantity = 0;
                         $data->price_access = 'all';
                         $data->{$action}['type'] = $action['value'];
                         $values[] = (int) $data->price_currency_id . ',' . (int) $data->price_product_id . ',' . (double) $data->price_value . ',' . (int) $data->price_min_quantity . ',' . $db->quote($data->price_access);
                     }
                     $query = 'INSERT INTO ' . hikashop_table('price') . ' (price_currency_id,price_product_id,price_value,price_min_quantity,price_access) VALUES (' . implode('),(', $values) . ')';
                     $db->setQuery($query);
                     $db->query();
                 }
             }
         }
     }
 }
コード例 #18
0
ファイル: cart.php プロジェクト: paisit/pyzid
                ?>

								</div>
							</div>
							<?php 
            }
            if ($group) {
                foreach ($this->rows as $j => $optionElement) {
                    if ($optionElement->cart_product_option_parent_id != $row->cart_product_id) {
                        continue;
                    }
                    if (!empty($optionElement->prices[0])) {
                        if (!isset($row->prices[0])) {
                            $row->prices[0]->price_value = 0;
                            $row->prices[0]->price_value_with_tax = 0;
                            $row->prices[0]->price_currency_id = hikashop_getCurrency();
                        }
                        foreach (get_object_vars($row->prices[0]) as $key => $value) {
                            if (is_object($value)) {
                                foreach (get_object_vars($value) as $key2 => $var2) {
                                    if (strpos($key2, 'price_value') !== false) {
                                        $row->prices[0]->{$key}->{$key2} += @$optionElement->prices[0]->{$key}->{$key2};
                                    }
                                }
                            } else {
                                if (strpos($key, 'price_value') !== false) {
                                    $row->prices[0]->{$key} += @$optionElement->prices[0]->{$key};
                                }
                            }
                        }
                    }
コード例 #19
0
ファイル: default.php プロジェクト: rodhoff/MNW
    ?>
" method="post" name="hikashop_currency_form_<?php 
    echo $module->id;
    ?>
">
		<input type="hidden" name="return_url" value="<?php 
    echo urlencode($redirectUrl);
    ?>
" />
		<?php 
    echo $currency->display('hikashopcurrency', hikashop_getCurrency(), 'class="hikashopcurrency" onchange="document.hikashop_currency_form_' . $module->id . '.submit();"');
    ?>
	</form>
<?php 
} else {
    echo $currency->display(null, hikashop_getCurrency(), 'class="hikashopcurrency" id="hikashopcurrency_' . $module->id . '" onchange="window.localPage.switchCurrency(this);"');
    ?>
<script type="text/javascript">
if(!window.localPage) window.localPage = {};
window.localPage.switchCurrency = function(el) {
	var url = "<?php 
    echo hikashop_completeLink('currency&task=update&hikashopcurrency={ID}');
    ?>
";
	url += ((url.indexOf("?") !== false) ? "?" : "&") + "return_url=<?php 
    echo urlencode($redirectUrl);
    ?>
";
	window.location = url.replace("{ID}", el.value);
};
</script>
コード例 #20
0
ファイル: cart.php プロジェクト: rodhoff/MNW
 function &loadFullCart($additionalInfos = false, $keepEmptyCart = false, $skipChecks = false)
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $config =& hikashop_config();
     $currencyClass = hikashop_get('class.currency');
     $productClass = hikashop_get('class.product');
     $main_currency = (int) $config->get('main_currency', 1);
     $currency_id = hikashop_getCurrency();
     if (!in_array($currency_id, $currencyClass->publishedCurrencies())) {
         $currency_id = $main_currency;
     }
     $zone_id = hikashop_getZone('shipping');
     if ($config->get('tax_zone_type', 'shipping') == 'billing') {
         $tax_zone_id = hikashop_getZone('billing');
     } else {
         $tax_zone_id = $zone_id;
     }
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $cart = new stdClass();
     $cart->products = $this->get(@$this->cart->cart_id, $keepEmptyCart, isset($this->cart->cart_type) ? $this->cart->cart_type : '');
     $cart->cart_id = (int) @$this->cart->cart_id;
     $cart->cart_type = @$this->cart->cart_type;
     $cart->cart_params = @$this->cart->cart_params;
     $cart->coupon = null;
     $cart->shipping = null;
     $cart->total = null;
     $cart->additional = array();
     if (!empty($cart->products)) {
         $ids = array();
         $mainIds = array();
         foreach ($cart->products as $product) {
             $ids[] = $product->product_id;
             if ($product->product_parent_id == '0') {
                 $mainIds[] = (int) $product->product_id;
             } else {
                 $mainIds[] = (int) $product->product_parent_id;
             }
         }
         $query = 'SELECT a.*, b.* FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('category') . ' AS b ON a.category_id = b.category_id WHERE a.product_id IN(' . implode(',', $mainIds) . ') ORDER BY a.ordering ASC';
         $database->setQuery($query);
         $categories = $database->loadObjectList();
         $quantityDisplayType = hikashop_get('type.quantitydisplay');
         foreach ($cart->products as $k => $row) {
             if ($row->product_parent_id != 0 && $row->cart_product_parent_id != '0') {
                 $row->product_quantity_layout = $cart->products[$row->cart_product_parent_id]->product_quantity_layout;
                 $row->product_min_per_order = $cart->products[$row->cart_product_parent_id]->product_min_per_order;
                 $row->product_max_per_order = $cart->products[$row->cart_product_parent_id]->product_max_per_order;
             }
             if (empty($row->product_quantity_layout) || $row->product_quantity_layout == 'inherit') {
                 $categoryQuantityLayout = '';
                 if (!empty($categories)) {
                     foreach ($categories as $category) {
                         if ($category->product_id == $row->product_id && !empty($category->category_quantity_layout) && $quantityDisplayType->check($category->category_quantity_layout, $app->getTemplate())) {
                             $categoryQuantityLayout = $category->category_quantity_layout;
                             break;
                         }
                     }
                 }
             }
             if (!empty($row->product_quantity_layout) && $row->product_quantity_layout != 'inherit') {
                 $qLayout = $row->product_quantity_layout;
             } elseif (!empty($categoryQuantityLayout) && $categoryQuantityLayout != 'inherit') {
                 $qLayout = $categoryQuantityLayout;
             } else {
                 $qLayout = $config->get('product_quantity_display', 'show_default');
             }
             $cart->products[$k]->product_quantity_layout = $qLayout;
         }
         JArrayHelper::toInteger($ids);
         $query = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type IN( \'product\',\'file\') ORDER BY file_ref_id ASC, file_ordering ASC';
         $database->setQuery($query);
         $images = $database->loadObjectList();
         if (!empty($images)) {
             foreach ($cart->products as $k => $row) {
                 $productClass->addFiles($cart->products[$k], $images);
             }
         }
         foreach ($cart->products as $k => $row) {
             if ($row->product_type == 'variant') {
                 foreach ($cart->products as $k2 => $row2) {
                     if ($row->product_parent_id == $row2->product_id) {
                         $cart->products[$k2]->variants[] =& $cart->products[$k];
                         break;
                     }
                 }
             }
         }
         $query = 'SELECT a.*,b.* FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id IN (' . implode(',', $ids) . ') ORDER BY a.ordering,b.characteristic_value';
         $database->setQuery($query);
         $characteristics = $database->loadObjectList();
         if (!empty($characteristics)) {
             foreach ($cart->products as $key => $product) {
                 if ($product->product_type != 'variant') {
                     $element =& $cart->products[$key];
                     $product_id = $product->product_id;
                     $mainCharacteristics = array();
                     foreach ($characteristics as $characteristic) {
                         if ($product_id == $characteristic->variant_product_id) {
                             $mainCharacteristics[$product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id] = $characteristic;
                         }
                         if (!empty($element->options)) {
                             foreach ($element->options as $k => $optionElement) {
                                 if ($optionElement->product_id == $characteristic->variant_product_id) {
                                     $mainCharacteristics[$optionElement->product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id] = $characteristic;
                                 }
                             }
                         }
                     }
                     JPluginHelper::importPlugin('hikashop');
                     $dispatcher = JDispatcher::getInstance();
                     $dispatcher->trigger('onAfterProductCharacteristicsLoad', array(&$element, &$mainCharacteristics, &$characteristics));
                     if (!empty($element->variants)) {
                         $this->addCharacteristics($element, $mainCharacteristics, $characteristics);
                     }
                     if (!empty($element->options)) {
                         foreach ($element->options as $k => $optionElement) {
                             if (!empty($optionElement->variants)) {
                                 $this->addCharacteristics($element->options[$k], $mainCharacteristics, $characteristics);
                             }
                         }
                     }
                 }
             }
         }
         $product_quantities = array();
         foreach ($cart->products as $row) {
             if (empty($product_quantities[$row->product_id])) {
                 $product_quantities[$row->product_id] = (int) @$row->cart_product_quantity;
             } else {
                 $product_quantities[$row->product_id] += (int) @$row->cart_product_quantity;
             }
             if (empty($product_quantities[$row->product_parent_id])) {
                 $product_quantities[$row->product_parent_id] = (int) @$row->cart_product_quantity;
             } else {
                 $product_quantities[$row->product_parent_id] += (int) @$row->cart_product_quantity;
             }
         }
         foreach ($cart->products as $k => $row) {
             $cart->products[$k]->cart_product_total_quantity = $product_quantities[$row->product_id];
             if ($row->product_parent_id) {
                 $cart->products[$k]->cart_product_total_variants_quantity = $product_quantities[$row->product_parent_id];
             } else {
                 $cart->products[$k]->cart_product_total_variants_quantity = $cart->products[$k]->cart_product_total_quantity;
             }
         }
         $currencyClass->getPrices($cart->products, $ids, $currency_id, $main_currency, $tax_zone_id, $discount_before_tax);
         if ($additionalInfos) {
             $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ref_id ASC, file_ordering ASC, file_id ASC';
             $database->setQuery($queryImage);
             $images = $database->loadObjectList();
             foreach ($cart->products as $k => $row) {
                 if (!empty($images)) {
                     foreach ($images as $image) {
                         if ($row->product_id == $image->file_ref_id) {
                             if (!isset($row->file_ref_id)) {
                                 foreach (get_object_vars($image) as $key => $name) {
                                     $cart->products[$k]->{$key} = $name;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 if (!isset($cart->products[$k]->file_name)) {
                     $cart->products[$k]->file_name = $row->product_name;
                 }
             }
         }
         foreach ($cart->products as $k => $row) {
             if (!empty($row->variants)) {
                 foreach ($row->variants as $k2 => $variant) {
                     $productClass->checkVariant($cart->products[$k]->variants[$k2], $row);
                 }
             }
         }
         $notUsable = array();
         $cartData = $this->loadCart($cart->cart_id);
         if (!$skipChecks) {
             $cart->products = array_reverse($cart->products);
             foreach ($cart->products as $k => $product) {
                 if (empty($product->product_id)) {
                     continue;
                 }
                 if (!empty($product->cart_product_quantity)) {
                     $oldQty = $product->cart_product_quantity;
                     if (@$cartData->cart_type != 'wishlist') {
                         $this->_checkQuantity($product, $product->cart_product_quantity, $cart->products, $product->cart_product_id);
                     }
                     if ($oldQty != $product->cart_product_quantity) {
                         $notUsable[$product->cart_product_id] = 0;
                         break;
                     }
                     if (!$config->get('display_add_to_cart_for_free_products', 0) && empty($product->prices)) {
                         $notUsable[$product->cart_product_id] = 0;
                         $app->enqueueMessage(JText::sprintf('PRODUCT_NOT_AVAILABLE', $product->product_name), 'notice');
                         continue;
                     }
                     if (empty($product->product_published)) {
                         $notUsable[$product->cart_product_id] = 0;
                         $app->enqueueMessage(JText::sprintf('PRODUCT_NOT_AVAILABLE', $product->product_name), 'notice');
                         continue;
                     }
                     if ($product->product_quantity != -1 && $product->product_quantity < $product->cart_product_quantity) {
                         $notUsable[$product->cart_product_id] = 0;
                         $app->enqueueMessage(JText::sprintf('NOT_ENOUGH_STOCK_FOR_PRODUCT', $product->product_name), 'notice');
                         continue;
                     }
                     if ($product->product_sale_start > time()) {
                         $notUsable[$product->cart_product_id] = 0;
                         $app->enqueueMessage(JText::sprintf('PRODUCT_NOT_YET_ON_SALE', $product->product_name), 'notice');
                         continue;
                     }
                     if (!empty($product->product_sale_end) && $product->product_sale_end < time()) {
                         $notUsable[$product->cart_product_id] = 0;
                         $app->enqueueMessage(JText::sprintf('PRODUCT_NOT_SOLD_ANYMORE', $product->product_name), 'notice');
                         continue;
                     }
                 }
             }
             $cart->products = array_reverse($cart->products);
         }
         if (!empty($notUsable)) {
             $this->update($notUsable, 1, 0, 'item');
             return $this->loadFullCart($additionalInfos);
         }
         $cart->number_of_items = 0;
         $group = $config->get('group_options', 0);
         foreach ($cart->products as $k => $row) {
             unset($cart->products[$k]->cart_modified);
             unset($cart->products[$k]->cart_coupon);
             $currencyClass->calculateProductPriceForQuantity($cart->products[$k]);
             if (!$group || !$row->cart_product_option_parent_id) {
                 $cart->number_of_items += $row->cart_product_quantity;
             }
         }
         $currencyClass->calculateTotal($cart->products, $cart->total, $currency_id);
         $cart->full_total =& $cart->total;
         JPluginHelper::importPlugin('hikashop');
         JPluginHelper::importPlugin('hikashoppayment');
         JPluginHelper::importPlugin('hikashopshipping');
         $dispatcher = JDispatcher::getInstance();
         $dispatcher->trigger('onAfterCartProductsLoad', array(&$cart));
         if (!empty($cart->additional)) {
             $currencyClass->addAdditionals($cart->additional, $cart->additional_total, $cart->full_total, $currency_id);
             $cart->full_total =& $cart->additional_total;
         }
         if (!empty($this->cart->cart_coupon) && $cart->cart_type != 'wishlist') {
             $discountClass = hikashop_get('class.discount');
             $discountData = $discountClass->load($this->cart->cart_coupon);
             if (@$discountData->discount_auto_load) {
                 $current_auto_coupon_key = $this->_generateHash($cart->products, $zone_id);
                 $previous_auto_coupon_key = $app->getUserState(HIKASHOP_COMPONENT . '.auto_coupon_key');
                 if ($current_auto_coupon_key != $previous_auto_coupon_key) {
                     $this->cart->cart_coupon = '';
                 }
             }
         }
         if (hikashop_level(1) && empty($this->cart->cart_coupon) && $cart->cart_type != 'wishlist') {
             $filters = array('discount_type=\'coupon\'', 'discount_published=1', 'discount_auto_load=1');
             hikashop_addACLFilters($filters, 'discount_access');
             $query = 'SELECT * FROM ' . hikashop_table('discount') . ' WHERE ' . implode(' AND ', $filters) . ' ORDER BY discount_minimum_order DESC, discount_minimum_products DESC';
             $this->database->setQuery($query);
             $coupons = $this->database->loadObjectList();
             if (!empty($coupons)) {
                 $discountClass = hikashop_get('class.discount');
                 $zoneClass = hikashop_get('class.zone');
                 $zones = $zoneClass->getZoneParents($zone_id);
                 foreach ($coupons as $coupon) {
                     $result = $discountClass->check($coupon, $cart->total, $zones, $cart->products, false);
                     if ($result) {
                         $auto_coupon_key = $this->_generateHash($cart->products, $zone_id);
                         $app->setUserState(HIKASHOP_COMPONENT . '.auto_coupon_key', $auto_coupon_key);
                         $app->setUserState(HIKASHOP_COMPONENT . '.coupon_code', '');
                         $this->update($coupon->discount_code, 1, 0, 'coupon', true);
                         if (empty($this->cart)) {
                             $this->cart = new stdClass();
                         }
                         $this->cart->cart_coupon = $coupon->discount_code;
                         static $done = false;
                         if ($done == false) {
                             $done = true;
                             return $this->loadFullCart($additionalInfos);
                         }
                         break;
                     }
                 }
             }
         }
         if (!empty($this->cart->cart_coupon) && $cart->cart_type != 'wishlist') {
             $zoneClass = hikashop_get('class.zone');
             $zones = $zoneClass->getZoneParents($zone_id);
             $cart->coupon = $discountClass->loadAndCheck($this->cart->cart_coupon, $cart->full_total, $zones, $cart->products, true);
             if (empty($cart->coupon)) {
                 if (!empty($this->cart)) {
                     $this->cart->cart_coupon = '';
                 }
             } else {
                 $cart->full_total =& $cart->coupon->total;
             }
         }
         if (hikashop_toFloat($cart->full_total->prices[0]->price_value_with_tax) <= 0) {
             $cart->full_total->prices[0]->price_value_with_tax = 0;
             $cart->full_total->prices[0]->price_value = 0;
             if (isset($cart->full_total->prices[0]->taxes)) {
                 unset($cart->full_total->prices[0]->taxes);
             }
         }
         $shipping_id = $app->getUserState(HIKASHOP_COMPONENT . '.shipping_id');
         if (!empty($shipping_id)) {
             $cart->shipping = $app->getUserState(HIKASHOP_COMPONENT . '.shipping_data');
             if (!empty($cart->shipping)) {
                 if (!is_array($cart->shipping)) {
                     $cart->shipping = array($cart->shipping);
                 } else {
                     $shippings = array();
                     foreach ($cart->shipping as $method) {
                         $group_key = $method->shipping_id;
                         if (!empty($method->shipping_warehouse_id)) {
                             $group_key .= '_';
                             if (is_array($method->shipping_warehouse_id)) {
                                 foreach ($method->shipping_warehouse_id as $key => $val) {
                                     $group_key .= $key . $val;
                                 }
                             } else {
                                 $group_key .= $method->shipping_warehouse_id;
                             }
                         }
                         $shippings[$group_key] = $method;
                     }
                     $cart->shipping = array_values($shippings);
                 }
                 $currencyClass = hikashop_get('class.currency');
                 $shipping =& $cart->shipping;
                 $currencyClass->processShippings($shipping, $cart);
                 $cart->full_total =& $currencyClass->addShipping($cart->shipping, $cart->full_total);
             }
         }
         $before_additional = !empty($cart->additional);
         $dispatcher->trigger('onAfterCartShippingLoad', array(&$cart));
         if (!$before_additional && !empty($cart->additional)) {
             $currencyClass->addAdditionals($cart->additional, $cart->additional_total, $cart->full_total, $currency_id);
             $cart->full_total =& $cart->additional_total;
         }
         if (hikashop_toFloat($cart->full_total->prices[0]->price_value_with_tax) <= 0) {
             $cart->full_total->prices[0]->price_value_with_tax = 0;
             $cart->full_total->prices[0]->price_value = 0;
             if (isset($cart->full_total->prices[0]->taxes)) {
                 unset($cart->full_total->prices[0]->taxes);
             }
         }
         $payment_id = $app->getUserState(HIKASHOP_COMPONENT . '.payment_id');
         if (!empty($payment_id)) {
             $cart->payment = $app->getUserState(HIKASHOP_COMPONENT . '.payment_data');
             if (!empty($cart->payment)) {
                 $currencyClass = hikashop_get('class.currency');
                 $payment =& $cart->payment;
                 $payments = array(&$payment);
                 $currencyClass->processPayments($payments, $cart);
                 $currencyClass->addPayment($cart->payment, $cart->full_total);
                 $cart->full_total =& $cart->payment->total;
             }
         }
         if (hikashop_toFloat($cart->full_total->prices[0]->price_value_with_tax) <= 0) {
             $cart->full_total->prices[0]->price_value_with_tax = 0;
             $cart->full_total->prices[0]->price_value = 0;
             if (isset($cart->full_total->prices[0]->taxes)) {
                 unset($cart->full_total->prices[0]->taxes);
             }
         }
     }
     if ($additionalInfos) {
         $app = JFactory::getApplication();
         $shipping_address = $app->getUserState(HIKASHOP_COMPONENT . '.shipping_address', 0);
         if (!empty($shipping_address)) {
             $this->loadAddress($cart, $shipping_address);
         }
         $billing_address = $app->getUserState(HIKASHOP_COMPONENT . '.billing_address', 0);
         if ($billing_address == $shipping_address) {
             $cart->billing_address =& $cart->shipping_address;
         } else {
             if (!empty($billing_address)) {
                 $this->loadAddress($cart, $billing_address, 'parent', 'billing');
             }
         }
         $this->calculateWeightAndVolume($cart);
     }
     if (!empty($cart->products) && isset($dispatcher)) {
         $dispatcher->trigger('onAfterFullCartLoad', array(&$cart));
     }
     return $cart;
 }
コード例 #21
0
ファイル: order.php プロジェクト: q0821/esportshop
 function save(&$order)
 {
     $new = false;
     $config =& hikashop_config();
     if (empty($order->order_id)) {
         if (!is_object($order)) {
             $order = new stdClass();
         }
         $order->order_created = time();
         if (empty($order->order_type)) {
             $order->order_type = 'sale';
         }
         $order->order_ip = hikashop_getIP();
         $order->old = new stdClass();
         if (empty($order->order_status)) {
             $order->order_status = $config->get('order_created_status', 'pending');
         }
         if (empty($order->order_currency_id)) {
             $order->order_currency_id = hikashop_getCurrency();
         }
         if (defined('MULTISITES_ID')) {
             $order->order_site_id = MULTISITES_ID;
         }
         $new = true;
     } else {
         if (empty($order->old)) {
             $order->old = $this->get($order->order_id);
         }
     }
     $order->order_modified = time();
     JPluginHelper::importPlugin('hikashop');
     JPluginHelper::importPlugin('hikashoppayment');
     JPluginHelper::importPlugin('hikashopshipping');
     $dispatcher = JDispatcher::getInstance();
     $order_type = '';
     if (!empty($order->old->order_type)) {
         $order_type = $order->old->order_type;
     }
     if (!empty($order->order_type)) {
         $order_type = $order->order_type;
     }
     $recalculate = false;
     if (!empty($order->product)) {
         $do = true;
         $dispatcher->trigger('onBeforeOrderProductsUpdate', array(&$order, &$do));
         if (!$do) {
             return false;
         }
         $productClass = hikashop_get('class.order_product');
         if (is_array($order->product)) {
             foreach ($order->product as $product) {
                 $productClass->update($product);
             }
         } else {
             $productClass->update($order->product);
         }
         $recalculate = true;
     }
     if (!$new && (isset($order->order_shipping_price) || isset($order->order_payment_price) || isset($order->order_discount_price))) {
         if (isset($order->order_shipping_tax_namekey) || isset($order->order_discount_tax_namekey) || isset($order->order_payment_tax_namekey)) {
             if (!empty($order->old->order_tax_info)) {
                 $order->order_tax_info = $order->old->order_tax_info;
                 foreach ($order->order_tax_info as $k => $tax) {
                     if (isset($order->order_shipping_tax_namekey) && $tax->tax_namekey == $order->order_shipping_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_shipping = @$order->order_shipping_tax;
                         unset($order->order_shipping_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_shipping)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_shipping);
                     }
                     if (isset($order->order_payment_tax_namekey) && $tax->tax_namekey == $order->order_payment_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_payment = @$order->order_payment_tax;
                         unset($order->order_payment_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_payment)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_payment);
                     }
                     if (isset($order->order_discount_tax_namekey) && $tax->tax_namekey == $order->order_discount_tax_namekey) {
                         $order->order_tax_info[$k]->tax_amount_for_coupon = @$order->order_discount_tax;
                         unset($order->order_discount_tax_namekey);
                     } elseif (isset($order->order_tax_info[$k]->tax_amount_for_coupon)) {
                         unset($order->order_tax_info[$k]->tax_amount_for_coupon);
                     }
                 }
             }
             if (isset($order->order_shipping_tax_namekey)) {
                 $order->order_tax_info[$order->order_shipping_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_namekey = $order->order_shipping_tax_namekey;
                 $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_amount_for_shipping = @$order->order_shipping_tax;
                 unset($order->order_shipping_tax_namekey);
             }
             if (isset($order->order_payment_tax_namekey)) {
                 $order->order_tax_info[$order->order_payment_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_payment_tax_namekey]->tax_namekey = $order->order_payment_tax_namekey;
                 $order->order_tax_info[$order->order_payment_tax_namekey]->tax_amount_for_payment = @$order->order_payment_tax;
                 unset($order->order_payment_tax_namekey);
             }
             if (isset($order->order_discount_tax_namekey)) {
                 $order->order_tax_info[$order->order_discount_tax_namekey] = new stdClass();
                 $order->order_tax_info[$order->order_discount_tax_namekey]->tax_namekey = $order->order_discount_tax_namekey;
                 $order->order_tax_info[$order->order_discount_tax_namekey]->tax_amount_for_coupon = @$order->order_discount_tax;
                 unset($order->order_discount_tax_namekey);
             }
         }
         $recalculate = true;
     }
     if ($recalculate) {
         $this->recalculateFullPrice($order);
     }
     $do = true;
     if ($new) {
         $dispatcher->trigger('onBeforeOrderCreate', array(&$order, &$do));
     } else {
         $dispatcher->trigger('onBeforeOrderUpdate', array(&$order, &$do));
     }
     if ($do) {
         if (isset($order->value)) {
             unset($order->value);
         }
         if (isset($order->order_current_lgid)) {
             unset($order->order_current_lgid);
         }
         if (isset($order->order_current_locale)) {
             unset($order->order_current_locale);
         }
         if (isset($order->mail_status)) {
             unset($order->mail_status);
         }
         if (isset($order->order_tax_info) && !is_string($order->order_tax_info)) {
             $order->order_tax_info = serialize($order->order_tax_info);
         }
         if (isset($order->order_currency_info) && !is_string($order->order_currency_info)) {
             $order->order_currency_info = serialize($order->order_currency_info);
         }
         if (isset($order->order_shipping_params) && !is_string($order->order_shipping_params)) {
             $order->order_shipping_params = serialize($order->order_shipping_params);
         }
         if (isset($order->order_payment_params) && !is_string($order->order_payment_params)) {
             $order->order_payment_params = serialize($order->order_payment_params);
         }
         if ($config->get('update_stock_after_confirm') && isset($order->order_status) && isset($order->old->order_status) && $order_type == 'sale') {
             $invoice_statuses = $config->get('invoice_order_statuses', 'confirmed,shipped');
             if (empty($invoice_statuses)) {
                 $invoice_statuses = 'confirmed,shipped';
             }
             $invoice_order_statuses = explode(',', $invoice_statuses);
             if ($order->old->order_status == 'created' && in_array($order->order_status, $invoice_order_statuses)) {
                 $this->loadProducts($order);
                 if (!empty($order->products)) {
                     $productClass = hikashop_get('class.order_product');
                     foreach ($order->products as $product) {
                         $product->change = 'minus';
                         $productClass->update($product);
                         unset($product->change);
                     }
                 }
             } elseif (in_array($order->old->order_status, $invoice_order_statuses) && $order->order_status == 'created') {
                 $this->loadProducts($order);
                 if (!empty($order->products)) {
                     $productClass = hikashop_get('class.order_product');
                     foreach ($order->products as $product) {
                         $product->change = 'plus';
                         $productClass->update($product);
                         unset($product->change);
                     }
                 }
             }
         }
         if (isset($order->order_status) && $order_type == 'sale') {
             $this->capturePayment($order, 0);
         }
         if (!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') {
             $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
             if (empty($valid_statuses)) {
                 $valid_statuses = array('confirmed', 'shipped');
             }
             $excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0);
             if (isset($order->order_full_price)) {
                 $total = $order->order_full_price;
             } elseif (isset($order->old->order_full_price)) {
                 $total = $order->old->order_full_price;
             } else {
                 $total = 0;
             }
             //new order for example
             if (in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) {
                 $query = 'SELECT MAX(a.order_invoice_id)+1 FROM ' . hikashop_table('order') . ' AS a WHERE a.order_type = \'sale\'';
                 $resetFrequency = $config->get('invoice_reset_frequency', '');
                 if (!empty($resetFrequency)) {
                     $y = (int) date('Y');
                     $m = 1;
                     $d = 1;
                     if ($resetFrequency == 'month') {
                         $m = (int) date('m');
                     }
                     if (strpos($resetFrequency, '/') !== false) {
                         list($d, $m) = explode('/', $resetFrequency, 2);
                         if ($d == '*') {
                             $d = (int) date('d');
                         } else {
                             $d = (int) $d;
                         }
                         if ($m == '*') {
                             $m = (int) date('m');
                         } else {
                             $m = (int) $m;
                         }
                         if ($d <= 0) {
                             $d = 1;
                         }
                         if ($m <= 0) {
                             $m = 1;
                         }
                     }
                     $query .= ' AND a.order_invoice_created >= ' . mktime(0, 0, 0, $m, $d, $y);
                 }
                 $this->database->setQuery($query);
                 $order->order_invoice_id = $this->database->loadResult();
                 if (empty($order->order_invoice_id)) {
                     $order->order_invoice_id = 1;
                 }
                 $order->order_invoice_number = hikashop_encode($order, 'invoice');
                 $order->order_invoice_created = time();
             }
         }
         if (empty($order->old)) {
             unset($order->old);
         }
         $order->order_id = parent::save($order);
         if (isset($order->order_tax_info) && is_string($order->order_tax_info)) {
             $order->order_tax_info = unserialize($order->order_tax_info);
         }
         if (isset($order->order_payment_params) && is_string($order->order_payment_params)) {
             $order->order_payment_params = unserialize($order->order_payment_params);
         }
         if (isset($order->order_shipping_params) && is_string($order->order_shipping_params)) {
             $order->order_shipping_params = unserialize($order->order_shipping_params);
         }
         if (!empty($order->order_id)) {
             $productClass = hikashop_get('class.order_product');
             if ($new && empty($order->order_number)) {
                 $order->order_number = hikashop_encode($order);
                 $updateOrder = new stdClass();
                 $updateOrder->order_id = $order->order_id;
                 $updateOrder->order_number = $order->order_number;
                 $config =& hikashop_config();
                 $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
                 if (empty($valid_statuses)) {
                     $valid_statuses = array('confirmed', 'shipped');
                 }
                 $created_status = $config->get('order_created_status', 'created');
                 if (in_array($created_status, $valid_statuses)) {
                     $order->order_invoice_id = $order->order_id;
                     $order->order_invoice_number = $order->order_number;
                     $order->order_invoice_created = time();
                     $updateOrder->order_invoice_id = $order->order_invoice_id;
                     $updateOrder->order_invoice_number = $order->order_invoice_number;
                 }
                 parent::save($updateOrder);
             }
             if (!empty($order->cart->products)) {
                 foreach ($order->cart->products as $k => $p) {
                     $order->cart->products[$k]->order_id = $order->order_id;
                 }
                 if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') {
                     foreach ($order->cart->products as $k => $product) {
                         $order->cart->products[$k]->no_update_qty = true;
                     }
                 }
                 $productClass->save($order->cart->products);
                 if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') {
                     foreach ($order->cart->products as $k => $product) {
                         unset($order->cart->products[$k]->no_update_qty);
                     }
                 }
                 if (!empty($order->order_discount_code) && $order_type == 'sale') {
                     $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times+1 WHERE discount_code=' . $this->database->Quote($order->order_discount_code) . ' AND discount_type=\'coupon\' LIMIT 1';
                     $this->database->setQuery($query);
                     $this->database->query();
                 }
                 if (!empty($order->cart->additional)) {
                     foreach ($order->cart->additional as $k => $p) {
                         $order->cart->additional[$k]->product_id = 0;
                         $order->cart->additional[$k]->order_product_quantity = 0;
                         if (!empty($p->name)) {
                             $order->cart->additional[$k]->order_product_name = $p->name;
                         }
                         $order->cart->additional[$k]->order_product_code = 'order additional';
                         if (!empty($p->value)) {
                             $order->cart->additional[$k]->order_product_options = $p->value;
                         }
                         if (!empty($p->price_value)) {
                             $order->cart->additional[$k]->order_product_price = $p->price_value;
                         }
                         $order->cart->additional[$k]->order_id = $order->order_id;
                     }
                     $productClass->save($order->cart->additional);
                 }
             } elseif (!empty($order->order_status) && !empty($order->old)) {
                 $update = $config->get('update_stock_after_confirm');
                 $config =& hikashop_config();
                 $cancelled_order_status = explode(',', $config->get('cancelled_order_status'));
                 $invoice_order_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped'));
                 if (empty($invoice_order_statuses)) {
                     $invoice_order_statuses = array('confirmed', 'shipped');
                 }
                 if (!empty($order->order_status) && in_array($order->order_status, $cancelled_order_status) && (empty($order->old->order_status) || !in_array($order->old->order_status, $cancelled_order_status))) {
                     if ($order_type == 'sale' && (in_array($order->order_status, $cancelled_order_status) && (in_array($order->old->order_status, $invoice_order_statuses) || !$update && $order->old->order_status == 'created'))) {
                         $productClass->cancelProductReservation($order->order_id);
                     }
                     if (!isset($order->order_discount_code)) {
                         $code = @$order->old->order_discount_code;
                     } else {
                         $code = $order->order_discount_code;
                     }
                     if (!empty($code) && $order_type == 'sale') {
                         $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times-1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1';
                         $this->database->setQuery($query);
                         $this->database->query();
                     }
                 }
                 if (!empty($order->order_status) && !in_array($order->order_status, $cancelled_order_status) && !empty($order->old->order_status) && in_array($order->old->order_status, $cancelled_order_status)) {
                     if ($order_type == 'sale' && (in_array($order->old->order_status, $cancelled_order_status) && (in_array($order->order_status, $invoice_order_statuses) || !$update && $order->order_status == 'created'))) {
                         $productClass->resetProductReservation($order->order_id);
                     }
                     if (!isset($order->order_discount_code)) {
                         $code = @$order->old->order_discount_code;
                     } else {
                         $code = $order->order_discount_code;
                     }
                     if (!empty($code) && $order_type == 'sale') {
                         $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times = discount_used_times + 1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1';
                         $this->database->setQuery($query);
                         $this->database->query();
                     }
                 }
             }
             if ($new) {
                 $send_email = $this->sendEmailAfterOrderCreation;
                 $dispatcher->trigger('onAfterOrderCreate', array(&$order, &$send_email));
                 if ($send_email) {
                     $this->loadOrderNotification($order, 'order_creation_notification');
                     $mail = hikashop_get('class.mail');
                     if (!empty($order->mail->dst_email)) {
                         $mail->sendMail($order->mail);
                     }
                     $this->mail_success =& $mail->mail_success;
                     $config =& hikashop_config();
                     $emails = $config->get('order_creation_notification_email');
                     if (!empty($emails)) {
                         $mail = hikashop_get('class.mail');
                         if (!empty($order->customer)) {
                             $user_email = $order->customer->user_email;
                             $user_name = $order->customer->name;
                         } else {
                             $order->customer = new stdClass();
                         }
                         $order->customer->user_email = explode(',', $emails);
                         $order->customer->name = ' ';
                         $this->loadOrderNotification($order, 'order_admin_notification');
                         $order->mail->subject = trim($order->mail->subject);
                         if (empty($order->mail->subject)) {
                             $order->mail->subject = JText::sprintf('NEW_ORDER_SUBJECT', $order->order_number, HIKASHOP_LIVE);
                         }
                         if (!empty($user_email)) {
                             $mail->mailer->addReplyTo(array($user_email, $user_name));
                         }
                         if (!empty($order->mail->dst_email)) {
                             $mail->sendMail($order->mail);
                         }
                         if (!empty($user_email)) {
                             $order->customer->user_email = $user_email;
                             $order->customer->name = $user_name;
                         }
                     }
                 }
             } else {
                 $send_email = @$order->history->history_notified;
                 $dispatcher->trigger('onAfterOrderUpdate', array(&$order, &$send_email));
                 if ($send_email) {
                     if (empty($order->mail) && isset($order->order_status)) {
                         $this->loadOrderNotification($order, 'order_status_notification');
                     } else {
                         $order->mail->data =& $order;
                         $order->mail->mail_name = 'order_status_notification';
                     }
                     if (!empty($order->mail)) {
                         $mail = hikashop_get('class.mail');
                         if (!empty($order->mail->dst_email)) {
                             $mail->sendMail($order->mail);
                         }
                         $this->mail_success =& $mail->mail_success;
                     }
                 }
             }
         }
         return $order->order_id;
     }
     return false;
 }
コード例 #22
0
ファイル: showcart.php プロジェクト: jhener79/vlakc
            }
            if (!@$cart->hide) {
                $total_quantity += (int) $cart->cart_product_quantity;
            }
        }
    }
    echo $total_quantity;
    ?>
</td>
			<td class="uk-text-right hikashop_cart_total_value">
<?php 
    if (empty($this->total->prices)) {
        $this->total->prices[0] = new stdClass();
        $this->total->prices[0]->price_value = 0;
        $this->total->prices[0]->price_value_with_tax = 0;
        $this->total->prices[0]->price_currency_id = hikashop_getCurrency();
    }
    if ($this->config->get('price_with_tax')) {
        echo $this->currencyHelper->format($this->total->prices[0]->price_value_with_tax, $this->total->prices[0]->price_currency_id);
    }
    if ($this->config->get('price_with_tax') == 2) {
        echo JText::_('PRICE_BEFORE_TAX');
    }
    if ($this->config->get('price_with_tax') == 2 || !$this->config->get('price_with_tax')) {
        echo $this->currencyHelper->format($this->total->prices[0]->price_value, $this->total->prices[0]->price_currency_id);
    }
    if ($this->config->get('price_with_tax') == 2) {
        echo JText::_('PRICE_AFTER_TAX');
    }
    ?>
			</td>
コード例 #23
0
ファイル: fedex.php プロジェクト: q0821/esportshop
    function _createPackage(&$data, &$product, &$rate, &$order, $includeDimension = false)
    {
        if (empty($data['weight'])) {
            $caracs = parent::_convertCharacteristics($product, $data);
            $data['weight_unit'] = $caracs['weight_unit'];
            $data['dimension_unit'] = $caracs['dimension_unit'];
            $data['weight'] = round($caracs['weight'], 2);
            if ($caracs['height'] != '' && $caracs['height'] != '0.00' && $caracs['height'] != 0) {
                $data['height'] = round($caracs['height'], 2);
                $data['length'] = round($caracs['length'], 2);
                $data['width'] = round($caracs['width'], 2);
            }
        }
        if ($data['weight_unit'] == 'KGS') {
            $data['weight_unit'] = 'KG';
        }
        if ($data['weight_unit'] == 'LBS') {
            $data['weight_unit'] = 'LB';
        }
        $currencyClass = hikashop_get('class.currency');
        $config =& hikashop_config();
        $this->main_currency = $config->get('main_currency', 1);
        $currency = hikashop_getCurrency();
        if (isset($data['price'])) {
            $price = $data['price'];
        } else {
            $price = $product->prices[0]->price_value;
        }
        if (@$this->shipping_currency_id != @$data['currency'] && !empty($data['currency'])) {
            $price = $currencyClass->convertUniquePrice($price, $this->shipping_currency_id, @$data['currency']);
        }
        if (!empty($rate->shipping_params->weight_approximation)) {
            $data['weight'] = $data['weight'] + $data['weight'] * $rate->shipping_params->weight_approximation / 100;
        }
        if (@$data['weight'] < 1) {
            $data['weight'] = 1;
        }
        if (!empty($rate->shipping_params->dim_approximation_h) && @$rate->shipping_params->use_dimensions == 1) {
            $data['height'] = $data['height'] + $data['height'] * $rate->shipping_params->dim_approximation_h / 100;
        }
        if (!empty($rate->shipping_params->dim_approximation_l) && @$rate->shipping_params->use_dimensions == 1) {
            $data['length'] = $data['length'] + $data['length'] * $rate->shipping_params->dim_approximation_l / 100;
        }
        if (!empty($rate->shipping_params->dim_approximation_w) && @$rate->shipping_params->use_dimensions == 1) {
            $data['width'] = $data['width'] + $data['width'] * $rate->shipping_params->dim_approximation_w / 100;
        }
        $options = '';
        $dimension = '';
        if (@$rate->shipping_params->include_price) {
            $options = '<PackageServiceOptions>
						<InsuredValue>
							<CurrencyCode>' . $data['currency_code'] . '</CurrencyCode>
							<MonetaryValue>' . $price . '</MonetaryValue>
						</InsuredValue>
					</PackageServiceOptions>';
        }
        if ($includeDimension) {
            if ($data['height'] != '' && $data['height'] != 0 && $data['height'] != '0.00') {
                $dimension = '<Dimensions>
							<UnitOfMeasurement>
								<Code>' . $data['dimension_unit'] . '</Code>
							</UnitOfMeasurement>
							<Length>' . $data['length'] . '</Length>
							<Width>' . $data['width'] . '</Width>
							<Height>' . $data['height'] . '</Height>
						</Dimensions>';
            }
        }
        static $id = 0;
        $xml = '<Package' . $id . '>
				<PackagingType>
					<Code>02</Code>
				</PackagingType>
				<Description>Shop</Description>
				' . $dimension . '
				<PackageWeight>
					<UnitOfMeasurement>
						<Code>' . $data['weight_unit'] . '</Code>
					</UnitOfMeasurement>
					<Weight>' . $data['weight'] . '</Weight>
				</PackageWeight>
				' . $options . '
			</Package' . $id . '>';
        $id++;
        return $xml;
    }
コード例 #24
0
ファイル: view.html.php プロジェクト: rodhoff/MNW
 function cart()
 {
     $cart = $this->initCart();
     if (!empty($cart->total->prices[0]->price_currency_id) && $cart->total->prices[0]->price_currency_id != hikashop_getCurrency()) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('CURRENCY_NOT_ACCEPTED_FOR_PAYMENT'));
     }
     $cartClass = hikashop_get('class.cart');
     $paymentType = $cartClass->checkSubscription($cart);
     $this->assignRef('paymentType', $paymentType);
     $cartClass = hikashop_get('helper.cart');
     $cartClass->cartCount(true);
     $this->assignRef('coupon', $cart->coupon);
     $this->assignRef('shipping', $cart->shipping);
     $this->assignRef('payment', $cart->payment);
     $this->assignRef('additional', $cart->additional);
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $config = hikashop_config();
     $this->assignRef('total', $cart->total);
     $this->assignRef('rows', $cart->products);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->init();
     $cart->cartCount(1);
     $cart->cartCount(1);
     $cart->getJS($this->params->get('url'));
     $config =& hikashop_config();
     $this->params->set('show_delete', $config->get('checkout_cart_delete', 1));
     $show_image = $config->get('show_cart_image');
     $this->params->set('show_cart_image', $show_image);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyClass);
     $image = hikashop_get('helper.image');
     $this->assignRef('image', $image);
     if (hikashop_level(2)) {
         $fieldsClass = hikashop_get('class.field');
         $this->assignRef('fieldsClass', $fieldsClass);
         $null = null;
         $this->extraFields['item'] = $fieldsClass->getFields('frontcomp', $null, 'item');
         $this->assignRef('extraFields', $this->extraFields);
     }
 }
コード例 #25
0
ファイル: listing_price.php プロジェクト: jhener79/vlakc
if (empty($this->row->prices)) {
    echo JText::_('FREE_PRICE');
} else {
    $first = true;
    echo JText::_('PRICE_BEGINNING');
    foreach ($this->row->prices as $price) {
        if ($first) {
            $first = false;
        } else {
            echo JText::_('PRICE_SEPARATOR');
        }
        if (!empty($this->unit) && isset($price->unit_price)) {
            $price =& $price->unit_price;
        }
        if (!isset($price->price_currency_id)) {
            $price->price_currency_id = hikashop_getCurrency();
        }
        echo '<span class="hikashop_product_price">';
        if ($this->params->get('price_with_tax')) {
            echo $this->currencyHelper->format(@$price->price_value_with_tax, $price->price_currency_id);
        }
        if ($this->params->get('price_with_tax') == 2) {
            echo JText::_('PRICE_BEFORE_TAX');
        }
        if ($this->params->get('price_with_tax') == 2 || !$this->params->get('price_with_tax')) {
            echo $this->currencyHelper->format(@$price->price_value, $price->price_currency_id);
        }
        if ($this->params->get('price_with_tax') == 2) {
            echo JText::_('PRICE_AFTER_TAX');
        }
        if ($this->params->get('show_original_price', '-1') == '-1') {
コード例 #26
0
ファイル: field.php プロジェクト: q0821/esportshop
 function check(&$field, &$value, $oldvalue)
 {
     $status = parent::check($field, $value, $oldvalue);
     if ($status) {
         if ($field->field_required && empty($value)) {
             return true;
         }
         $zone_id = hikashop_getZone('shipping');
         $discount = hikashop_get('class.discount');
         $zoneClass = hikashop_get('class.zone');
         $zones = $zoneClass->getZoneParents($zone_id);
         $total = new stdClass();
         $price = new stdClass();
         $price->price_value_with_tax = 0;
         $price->price_value = 0;
         $price->price_currency_id = hikashop_getCurrency();
         $total->prices = array($price);
         if (empty($field->coupon)) {
             $field->coupon = array();
         }
         $products = array();
         $field->coupon[$value] = $discount->loadAndCheck($value, $total, $zones, $products, true);
         if (empty($field->coupon[$value])) {
             $app = JFactory::getApplication();
             $app->enqueueMessage(JRequest::getVar('coupon_error_message'), 'notice');
             $status = false;
         }
         static $validCoupons = array();
         if (!isset($validCoupons[$value])) {
             $validCoupons[$value] = 1;
         } else {
             $validCoupons[$value]++;
         }
         if ($field->coupon[$value]->discount_quota > 0) {
             $left = $field->coupon[$value]->discount_quota - $field->coupon[$value]->discount_used_times;
             if ($left < $validCoupons[$value]) {
                 if ($left > 0) {
                     $app = JFactory::getApplication();
                     $app->enqueueMessage('You cannot use the coupon ' . $value . ' more than ' . $left . ' times !');
                 }
                 $status = false;
             }
         }
     }
     return $status;
 }
コード例 #27
0
ファイル: kashflow.php プロジェクト: rodhoff/MNW
 private function getCustomerCurrency(&$customer, &$order)
 {
     if (!empty($customer['CurrencyID'])) {
         return $customer['CurrencyID'];
     }
     if (!empty($order->order_currency_id)) {
         $currency_id = $order->order_currency_id;
     } else {
         $currency_id = hikashop_getCurrency();
     }
     $currencies = $this->makeRequest('GetCurrencies', array());
     if (!$currencies) {
         return 0;
     }
     $currency_code = $this->getCurrencyCode($currency_id);
     if (!is_array($currencies->GetCurrenciesResult->Currencies)) {
         $currencies->GetCurrenciesResult->Currencies = array($currencies->GetCurrenciesResult->Currencies);
     }
     foreach ($currencies->GetCurrenciesResult->Currencies as $currency) {
         if (empty($currency_id)) {
             return $currency->CurrencyId;
         }
         if ($currency_code && $currency->CurrencyCode == $currency_code) {
             return $currency->CurrencyId;
         }
     }
     return @$currencies->GetCurrenciesResult->Currencies[0]->CurrencyId;
 }
コード例 #28
0
ファイル: order.php プロジェクト: q0821/esportshop
 function pay()
 {
     if (!$this->_check()) {
         return false;
     }
     $order_id = hikashop_getCID('order_id');
     if (empty($order_id)) {
         parent::listing();
         return false;
     }
     $class = hikashop_get('class.order');
     $order = $class->loadFullOrder($order_id, true);
     if (empty($order->order_id)) {
         $app =& JFactory::getApplication();
         $app->enqueueMessage('The order ' . $order_id . ' could not be found');
         parent::listing();
         return false;
     }
     $config =& hikashop_config();
     $unpaid_statuses = explode(',', $config->get('order_unpaid_statuses', 'created'));
     if (!in_array($order->order_status, $unpaid_statuses)) {
         $app =& JFactory::getApplication();
         $app->enqueueMessage('The order ' . $order->order_number . ' cannot be paid anymore.');
         parent::listing();
         return false;
     }
     if (empty($order->order_currency_id)) {
         $null = new stdClass();
         $null->order_currency_id = hikashop_getCurrency();
         $null->order_id = $order->order_id;
         $order->order_currency_id = $null->order_currency_id;
         $class->save($null);
     }
     $new_payment_method = JRequest::getVar('new_payment_method', '');
     $config =& hikashop_config();
     if ($config->get('allow_payment_change', 1) && !empty($new_payment_method)) {
         $new_payment_method = explode('_', $new_payment_method);
         $payment_id = array_pop($new_payment_method);
         $payment_method = implode('_', $new_payment_method);
         if ($payment_id != $order->order_payment_id || $payment_method != $order->order_payment_method) {
             $updateOrder = new stdClass();
             $updateOrder->order_id = $order->order_id;
             $updateOrder->order_payment_id = $payment_id;
             $updateOrder->order_payment_method = $payment_method;
             $paymentClass = hikashop_get('class.payment');
             $payment = $paymentClass->get($payment_id);
             if (!empty($payment->payment_params) && is_string($payment->payment_params)) {
                 $payment->payment_params = unserialize($payment->payment_params);
             }
             $full_price_without_payment = $order->order_full_price - $order->order_payment_price;
             $new_payment = $payment;
             $new_payment_price = $paymentClass->computePrice($order, $new_payment, $full_price_without_payment, @$payment->payment_price, hikashop_getCurrency());
             $new_payment_tax = @$new_payment->payment_tax;
             $updateOrder->order_payment_price = $new_payment_price;
             $updateOrder->order_full_price = $full_price_without_payment + $new_payment_price + $new_payment_tax;
             $updateOrder->history = new stdClass();
             $updateOrder->history->history_payment_id = $payment_id;
             $updateOrder->history->history_payment_method = $payment_method;
             $class->save($updateOrder);
             $order->order_payment_id = $payment_id;
             $order->order_payment_method = $payment_method;
             $order->order_payment_price = $updateOrder->order_payment_price;
             $order->order_full_price = $updateOrder->order_full_price;
         }
     }
     $userClass = hikashop_get('class.user');
     $order->customer = $userClass->get($order->order_user_id);
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . hikashop_table('payment') . ' WHERE payment_type=' . $db->Quote($order->order_payment_method);
     $db->setQuery($query);
     $paymentData = $db->loadObjectList('payment_id');
     $pluginsClass = hikashop_get('class.plugins');
     $pluginsClass->params($paymentData, 'payment');
     if (empty($paymentData)) {
         $app =& JFactory::getApplication();
         $app->enqueueMessage('The payment method ' . $order->order_payment_method . ' could not be found');
         parent::listing();
         return false;
     }
     $order->cart =& $order;
     $order->cart->coupon = new stdClass();
     $price = new stdClass();
     $price->price_value_with_tax = $order->order_full_price;
     $order->cart->full_total = new stdClass();
     $order->cart->full_total->prices = array($price);
     $price2 = new stdClass();
     $total = 0;
     $class = hikashop_get('class.currency');
     $order->cart->total = new stdClass();
     $price2 = $class->calculateTotal($order->products, $order->cart->total, $order->order_currency_id);
     $order->cart->coupon->discount_value =& $order->order_discount_price;
     $shippingClass = hikashop_get('class.shipping');
     $methods = $shippingClass->getMethods($order->cart);
     $data = hikashop_import('hikashopshipping', $order->order_shipping_method);
     if (!empty($data)) {
         $order->cart->shipping = $data->onShippingSave($order->cart, $methods, $order->order_shipping_id);
     }
     $app = JFactory::getApplication();
     $app->setUserState(HIKASHOP_COMPONENT . '.shipping_address', $order->order_shipping_address_id);
     $app->setUserState(HIKASHOP_COMPONENT . '.billing_address', $order->order_billing_address_id);
     ob_start();
     $data = hikashop_import('hikashoppayment', $order->order_payment_method);
     if (!empty($data)) {
         $needCC = false;
         if (method_exists($data, 'needCC')) {
             $method =& $paymentData[$order->order_payment_id];
             $needCC = $data->needCC($method);
         }
         if (!$needCC) {
             $itemid_for_checkout = $config->get('checkout_itemid', '0');
             if ($itemid_for_checkout) {
                 global $Itemid;
                 $Itemid = $itemid_for_checkout;
             }
             if (method_exists($data, 'onAfterOrderConfirm')) {
                 $data->onAfterOrderConfirm($order, $paymentData, $order->order_payment_id);
             }
         } else {
             $paymentClass = hikashop_get('class.payment');
             $do = false;
             $app->setUserState(HIKASHOP_COMPONENT . '.payment_method', $order->order_payment_method);
             $app->setUserState(HIKASHOP_COMPONENT . '.payment_id', $order->order_payment_id);
             $app->setUserState(HIKASHOP_COMPONENT . '.payment_data', $method);
             if ($paymentClass->readCC()) {
                 $do = true;
                 if (method_exists($data, 'onBeforeOrderCreate')) {
                     $data->onBeforeOrderCreate($order, $do);
                 }
             }
             if (!$do) {
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_number', '');
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_month', '');
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_year', '');
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_CCV', '');
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_type', '');
                 $app->setUserState(HIKASHOP_COMPONENT . '.cc_owner', '');
                 $params = '';
                 $js = '';
                 echo hikashop_getLayout('checkout', 'ccinfo', $params, $js);
             } else {
                 $order->history->history_notified = 1;
                 $class = hikashop_get('class.order');
                 $updateOrder = new stdClass();
                 $updateOrder->order_id = $order->order_id;
                 $updateOrder->order_status = $order->order_status;
                 $updateOrder->order_payment_id = $payment_id;
                 $updateOrder->order_payment_method = $payment_method;
                 $updateOrder->history =& $order->history;
                 $class->save($updateOrder);
                 $app->redirect(hikashop_completeLink('checkout&task=after_end', false, true));
             }
         }
     }
     $html = ob_get_clean();
     if (empty($html)) {
         $app =& JFactory::getApplication();
         $app->enqueueMessage('The payment method ' . $order->order_payment_method . ' does not handle payments after the order has been created');
         parent::listing();
         return false;
     }
     echo $html;
     return true;
 }
コード例 #29
0
ファイル: filter.php プロジェクト: q0821/esportshop
    function display($filter, $divName, &$parent, $datas = '')
    {
        $selected = parent::display($filter, $divName, $parent);
        if (!empty($selected) && !empty($selected[0])) {
            $values = parent::display($filter, $divName, $parent, '_values');
            if (!is_array($values)) {
                $values = explode(' - ', $values);
            }
            if ($filter->filter_deletable && $values[0] != 'none' && (isset($values[0]) && !in_array($selected[0], array(" ", '')))) {
                $html = parent::displayInList($filter, $divName, $values);
                return $html;
            }
        }
        $cursorStep = '';
        $html = '';
        $cursorMin = 0;
        $cursorMax = 1000;
        $cursorEffect = '';
        $cursorWidth = 'width:250px;';
        $float = '';
        $deleteButton = '';
        if (!empty($datas) && $filter->filter_dynamic) {
            $nameMax = 'max_' . $filter->filter_namekey;
            $nameMin = 'min_' . $filter->filter_namekey;
            $array = $datas['limits'];
            if (!empty($array->{$nameMax})) {
                $cursorMax = (double) $array->{$nameMax};
            } else {
                $cursorMax = 1000;
            }
            if (!empty($array->{$nameMin})) {
                $cursorMin = (double) $array->{$nameMin};
            } else {
                $cursorMin = 0;
            }
        }
        if ($cursorMin == 0 && $filter->filter_options['cursor_min'] != 'none' && isset($filter->filter_options['cursor_min']) && !in_array($filter->filter_options['cursor_min'], array(" ", ''))) {
            $cursorMin = $filter->filter_options['cursor_min'];
        }
        if ($cursorMax == 1000 && !empty($filter->filter_options['cursor_max'])) {
            $cursorMax = $filter->filter_options['cursor_max'];
        }
        $minVal = $cursorMin;
        $maxVal = $cursorMax;
        if (!empty($filter->filter_options['cursor_effect'])) {
            $cursorEffect = 'animate: true,';
        }
        if (!empty($filter->filter_options['cursor_width'])) {
            $cursorWidth = 'width:' . $filter->filter_options['cursor_width'] . 'px;';
        }
        if (!empty($filter->filter_options['cursor_step'])) {
            $cursorStep = 'step:' . $filter->filter_options['cursor_step'] . ',';
        }
        if (isset($values)) {
            if (is_array($values) && count($values) != 2) {
                $data =& $values[0];
            } else {
                $data =& $values;
            }
            if (isset($data) && (is_array($data) || !in_array($data, array(" ", '')))) {
                if (!is_array($data)) {
                    $data = explode(' - ', $data);
                }
                $minVal = (double) @$data[0];
                $maxVal = (double) @$data[1];
            }
        }
        if ($minVal > $maxVal) {
            $tmp = $maxVal;
            $maxVal = $minVal;
            $minVal = $tmp;
        }
        if ($cursorMin > $cursorMax) {
            $tmp = $cursorMax;
            $cursorMax = $cursorMin;
            $cursorMin = $tmp;
        }
        $onClick = '';
        if ($filter->filter_direct_application) {
            $onClick = 'document.getElementById(\'slider_' . $filter->filter_namekey . '_' . $divName . '\').value="";document.forms[\'hikashop_filter_form_' . $divName . '\'].submit();';
        }
        $currency = '';
        if ($filter->filter_data == 'price') {
            $currencyClass = hikashop_get('class.currency');
            $currencies = null;
            $crurency_id = hikashop_getCurrency();
            $currencies = $currencyClass->getCurrencies($crurency_id, $currencies);
            $format = $currencies[$crurency_id]->currency_format;
            if (strpos($format, '%n') !== false) {
                $currency .= ' ' . $currencies[$crurency_id]->currency_symbol;
            }
            if (strpos($format, '%i') !== false) {
                $currency .= ' ' . $currencies[$crurency_id]->currency_code;
            }
        }
        $js = '
if(!hkjQuery) window.hkjQuery = window.jQuery;
hkjQuery(document).ready(function(){
	hkjQuery("#slider_' . $filter->filter_namekey . '_' . $divName . '").prop(\'slide\',null).slider({
		' . $cursorEffect . '
		range: true,
		min: ' . $cursorMin . ',
		max: ' . $cursorMax . ',
		' . $cursorStep . '
		values: [' . $minVal . ', ' . $maxVal . '],
		slide: function( event, ui ) {
			hkjQuery( "#filter_' . $filter->filter_namekey . '_' . $divName . '_values" ).val(  ui.values[ 0 ] + " - " + ui.values[ 1 ] );
			hkjQuery( "#filter_' . $filter->filter_namekey . '_' . $divName . '" ).val(1);
			hkjQuery( "#filter_span_' . $filter->filter_namekey . '_' . $divName . '" ).html(  ui.values[ 0 ] + "' . $currency . ' - " + ui.values[ 1 ] + "' . $currency . '" );
		},
		change: function( event, ui ) {' . $onClick . '
		}
	});
	hkjQuery( "#filter_' . $filter->filter_namekey . '_' . $divName . '_values" ).val(  hkjQuery( "#slider_' . $filter->filter_namekey . '_' . $divName . '" ).slider( "values", 0 ) + " - " + hkjQuery( "#slider_' . $filter->filter_namekey . '_' . $divName . '" ).slider( "values", 1 ) );
	hkjQuery( "#filter_span_' . $filter->filter_namekey . '_' . $divName . '" ).html(  hkjQuery( "#slider_' . $filter->filter_namekey . '_' . $divName . '" ).slider( "values", 0 ) + "' . $currency . ' - " + hkjQuery( "#slider_' . $filter->filter_namekey . '_' . $divName . '" ).slider( "values", 1 ) + "' . $currency . '" );

	hkjQuery(\'#dialog_link, ul#icons li\').hover(
		function() { hkjQuery(this).addClass(\'ui-state-hover\'); },
		function() { hkjQuery(this).removeClass(\'ui-state-hover\'); }
	);
});';
        if (HIKASHOP_PHP5) {
            $doc = JFactory::getDocument();
        } else {
            $doc =& JFactory::getDocument();
        }
        $doc->addScriptDeclaration("\n<!--\n" . $js . "\n//-->\n");
        hikashop_loadJslib('jquery');
        hikashop_loadJslib('jquery-ui');
        $hasValue = '';
        if (!empty($selected) && $selected[0] == 1 && $values[0] != 'none' && (isset($data) && !in_array($data, array(" ", '')))) {
            $deleteButton = '  ' . parent::getDeleteButton($filter, $divName, '11', $html, '', true);
            $hasValue = '1';
        }
        if ($filter->filter_options['title_position'] == 'left') {
            $float = 'float:left;';
        }
        $html = '<div style="' . $cursorWidth . ' ' . $float . ' margin-top:10px; margin-bottom:10px;" id="slider_' . $filter->filter_namekey . '_' . $divName . '"></div>';
        $html = $this->cursorTitlePosition($filter, $html, $cursorWidth, $divName, $deleteButton, $hasValue);
        return $html;
    }
コード例 #30
0
ファイル: currency.php プロジェクト: q0821/esportshop
 function convertPayments(&$payments)
 {
     $config =& hikashop_config();
     $main_currency = (int) $config->get('main_currency', 1);
     $currency_id = hikashop_getCurrency();
     if (!in_array($currency_id, $this->publishedCurrencies())) {
         $currency_id = $main_currency;
     }
     $currencies = array();
     foreach ($payments as $k => $payment) {
         if (isset($payment->payment_params->payment_currency) && @$payment->payment_params->payment_currency != $currency_id) {
             $currencies[$payment->payment_params->payment_currency] = $payment->payment_params->payment_currency;
         }
     }
     if (!empty($currencies)) {
         $currencies[$currency_id] = $currency_id;
         $currencies[$main_currency] = $main_currency;
         $null = null;
         $currencies = $this->getCurrencies($currencies, $null);
         $unset = array();
         foreach ($payments as $k => $payment) {
             if (empty($payment->payment_params->payment_currency)) {
                 continue;
             }
             if ($payment->payment_params->payment_currency != $currency_id) {
                 if (isset($currencies[$payment->payment_params->payment_currency]) && isset($currencies[$currency_id]) && isset($currencies[$main_currency])) {
                     $payments[$k]->payment_price_orig = $payments[$k]->payment_price;
                     $payments[$k]->payment_currency_orig = $payments[$k]->payment_params->payment_currency;
                     $payments[$k]->payment_params->payment_currency = $currency_id;
                     $srcCurrency = $currencies[$payment->payment_currency_orig];
                     $dstCurrency = $currencies[$currency_id];
                     $mainCurrency = $currencies[$main_currency];
                     if ($srcCurrency->currency_id != $mainCurrency->currency_id) {
                         if (bccomp($srcCurrency->currency_percent_fee, 0, 2)) {
                             $payments[$k]->payment_price += $payments[$k]->payment_price * floatval($srcCurrency->currency_percent_fee) / 100.0;
                         }
                         if (bccomp($srcCurrency->currency_rate, 0, 2)) {
                             $payments[$k]->payment_price = floatval($payments[$k]->payment_price) / floatval($srcCurrency->currency_rate);
                         }
                     }
                     if ($dstCurrency->currency_id != $mainCurrency->currency_id) {
                         $payments[$k]->payment_price = floatval($payments[$k]->payment_price) * floatval($dstCurrency->currency_rate);
                         if (bccomp($dstCurrency->currency_percent_fee, 0, 2)) {
                             $payments[$k]->payment_price += $payments[$k]->payment_price * floatval($dstCurrency->currency_percent_fee) / 100.0;
                         }
                     }
                 } else {
                     $unset[] = $k;
                 }
             }
         }
         if (!empty($unset)) {
             foreach ($unset as $u) {
                 unset($payments[$u]);
             }
         }
     }
 }