function listProductUpdateData($products, $setUrl = 0) { $jshopConfig = JSFactory::getConfig(); $userShop = JSFactory::getUserShop(); $taxes = JSFactory::getAllTaxes(); if ($jshopConfig->product_list_show_manufacturer) { $manufacturers = JSFactory::getAllManufacturer(); } if ($jshopConfig->product_list_show_vendor) { $vendors = JSFactory::getAllVendor(); } if ($jshopConfig->show_delivery_time) { $deliverytimes = JSFactory::getAllDeliveryTime(); } $image_path = $jshopConfig->image_product_live_path; $noimage = $jshopConfig->noimage; JPluginHelper::importPlugin('jshoppingproducts'); $dispatcher = JDispatcher::getInstance(); foreach ($products as $key => $value) { $dispatcher->trigger('onListProductUpdateDataProduct', array(&$products, &$key, &$value)); $use_userdiscount = 1; if ($jshopConfig->user_discount_not_apply_prod_old_price && $products[$key]->product_old_price > 0) { $use_userdiscount = 0; } $products[$key]->_original_product_price = $products[$key]->product_price; $products[$key]->product_price_wp = $products[$key]->product_price; $products[$key]->product_price_default = 0; if ($jshopConfig->product_list_show_min_price) { if ($products[$key]->min_price > 0) { $products[$key]->product_price = $products[$key]->min_price; } } $products[$key]->show_price_from = 0; if ($jshopConfig->product_list_show_min_price && $value->different_prices) { $products[$key]->show_price_from = 1; } $products[$key]->product_price = getPriceFromCurrency($products[$key]->product_price, $products[$key]->currency_id); $products[$key]->product_old_price = getPriceFromCurrency($products[$key]->product_old_price, $products[$key]->currency_id); $products[$key]->product_price_wp = getPriceFromCurrency($products[$key]->product_price_wp, $products[$key]->currency_id); $products[$key]->product_price = getPriceCalcParamsTax($products[$key]->product_price, $products[$key]->tax_id); $products[$key]->product_old_price = getPriceCalcParamsTax($products[$key]->product_old_price, $products[$key]->tax_id); $products[$key]->product_price_wp = getPriceCalcParamsTax($products[$key]->product_price_wp, $products[$key]->tax_id); if ($userShop->percent_discount && $use_userdiscount) { $products[$key]->product_price_default = $products[$key]->_original_product_price; $products[$key]->product_price_default = getPriceFromCurrency($products[$key]->product_price_default, $products[$key]->currency_id); $products[$key]->product_price_default = getPriceCalcParamsTax($products[$key]->product_price_default, $products[$key]->tax_id); $products[$key]->product_price = getPriceDiscount($products[$key]->product_price, $userShop->percent_discount); $products[$key]->product_old_price = getPriceDiscount($products[$key]->product_old_price, $userShop->percent_discount); $products[$key]->product_price_wp = getPriceDiscount($products[$key]->product_price_wp, $userShop->percent_discount); } if ($jshopConfig->list_products_calc_basic_price_from_product_price) { $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price_wp); } else { $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price); } if ($value->tax_id) { $products[$key]->tax = $taxes[$value->tax_id]; } if ($jshopConfig->product_list_show_manufacturer && $value->product_manufacturer_id && isset($manufacturers[$value->product_manufacturer_id])) { $products[$key]->manufacturer = $manufacturers[$value->product_manufacturer_id]; } else { $products[$key]->manufacturer = new stdClass(); $products[$key]->manufacturer->name = ''; } if ($jshopConfig->admin_show_product_extra_field) { $products[$key]->extra_field = getProductExtraFieldForProduct($value); } else { $products[$key]->extra_field = ''; } if ($jshopConfig->product_list_show_vendor) { $vendordata = $vendors[$value->vendor_id]; $vendordata->products = SEFLink("index.php?option=com_jshopping&controller=vendor&task=products&vendor_id=" . $vendordata->id, 1); $products[$key]->vendor = $vendordata; } else { $products[$key]->vendor = ''; } if ($jshopConfig->hide_delivery_time_out_of_stock && $products[$key]->product_quantity <= 0) { $products[$key]->delivery_times_id = 0; $value->delivery_times_id = 0; } if ($jshopConfig->show_delivery_time && $value->delivery_times_id) { $products[$key]->delivery_time = $deliverytimes[$value->delivery_times_id]; } else { $products[$key]->delivery_time = ''; } $products[$key]->_display_price = getDisplayPriceForProduct($products[$key]->product_price); if (!$products[$key]->_display_price) { $products[$key]->product_old_price = 0; $products[$key]->product_price_default = 0; $products[$key]->basic_price_info['price_show'] = 0; $products[$key]->tax = 0; $jshopConfig->show_plus_shipping_in_product = 0; } if ($jshopConfig->product_list_show_qty_stock) { $products[$key]->qty_in_stock = getDataProductQtyInStock($products[$key]); } $image = getPatchProductImage($products[$key]->image, 'thumb'); $products[$key]->product_name_image = $products[$key]->image; $products[$key]->product_thumb_image = $image; if (!$image) { $image = $noimage; } $products[$key]->image = $image_path . "/" . $image; $products[$key]->template_block_product = "product.php"; if (!$jshopConfig->admin_show_product_labels) { $products[$key]->label_id = null; } if ($products[$key]->label_id) { $image = getNameImageLabel($products[$key]->label_id); if ($image) { $products[$key]->_label_image = $jshopConfig->image_labels_live_path . "/" . $image; } $products[$key]->_label_name = getNameImageLabel($products[$key]->label_id, 2); } if ($jshopConfig->display_short_descr_multiline) { $products[$key]->short_description = nl2br($products[$key]->short_description); } } if ($setUrl) { addLinkToProducts($products, 0, 1); } $dispatcher->trigger('onListProductUpdateData', array(&$products)); return $products; }
function getDisplayPriceFront() { $display_price = $this->display_price_front; if ($this->use_extend_display_price_rule > 0) { $adv_user = JSFactory::getUserShop(); $country_id = $adv_user->country; $client_type = $adv_user->client_type; if (!$adv_user->user_id) { $adv_user = JSFactory::getUserShopGuest(); $country_id = $adv_user->country; $client_type = $adv_user->client_type; } if (!$country_id) { $country_id = $this->default_country; } if ($country_id) { $configDisplayPrice = JSFactory::getTable('configDisplayPrice', 'jshop'); $rows = $configDisplayPrice->getList(); foreach ($rows as $v) { if (in_array($country_id, $v->countries)) { if ($client_type == 2) { $display_price = $v->display_price_firma; } else { $display_price = $v->display_price; } } } } } return $display_price; }
function myaccount() { $jshopConfig = JSFactory::getConfig(); checkUserLogin(); $user = JFactory::getUser(); $adv_user = JSFactory::getUserShop(); $lang = JSFactory::getLang(); $country = JTable::getInstance('country', 'jshop'); $country->load($adv_user->country); $field_country_name = $lang->get("name"); $adv_user->country = $country->{$field_country_name}; $group = JTable::getInstance('userGroup', 'jshop'); $group->load($adv_user->usergroup_id); $adv_user->groupname = $group->usergroup_name; $adv_user->discountpercent = floatval($group->usergroup_discount); $seo = JTable::getInstance("seo", "jshop"); $seodata = $seo->loadData("myaccount"); if ($seodata->title == "") { $seodata->title = _JSHOP_MY_ACCOUNT; } setMetaData($seodata->title, $seodata->keyword, $seodata->description); $tmp_fields = $jshopConfig->getListFieldsRegister(); $config_fields = $tmp_fields['editaccount']; JPluginHelper::importPlugin('jshoppingcheckout'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeDisplayMyAccount', array()); $view_name = "user"; $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name); $view = $this->getView($view_name, getDocumentType(), '', $view_config); $view->setLayout("myaccount"); $view->assign('config', $jshopConfig); $view->assign('user', $adv_user); $view->assign('config_fields', $config_fields); $view->assign('href_user_group_info', SEFLink('index.php?option=com_jshopping&controller=user&task=groupsinfo')); $view->assign('href_edit_data', SEFLink('index.php?option=com_jshopping&controller=user&task=editaccount', 0, 0, $jshopConfig->use_ssl)); $view->assign('href_show_orders', SEFLink('index.php?option=com_jshopping&controller=user&task=orders', 0, 0, $jshopConfig->use_ssl)); $view->assign('href_logout', SEFLink('index.php?option=com_jshopping&controller=user&task=logout')); $dispatcher->trigger('onBeforeDisplayMyAccountView', array(&$view)); $view->display(); }
function step5save() { $session = JFactory::getSession(); $jshopConfig = JSFactory::getConfig(); $db = JFactory::getDBO(); $checkout = JModelLegacy::getInstance('checkout', 'jshop'); $mainframe = JFactory::getApplication(); $checkout->checkStep(5); $checkagb = JRequest::getVar('agb'); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onLoadStep5save', array(&$checkagb)); $lang = JSFactory::getLang(); $user = JFactory::getUser(); if ($user->id) { $adv_user = JSFactory::getUserShop(); } else { $adv_user = JSFactory::getUserShopGuest(); } $cart = JModelLegacy::getInstance('cart', 'jshop'); $cart->load(); $cart->setDisplayItem(1, 1); $cart->setDisplayFreeAttributes(); if ($jshopConfig->check_php_agb && $checkagb != 'on') { JError::raiseWarning("", _JSHOP_ERROR_AGB); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl)); return 0; } if (!$cart->checkListProductsQtyInStore()) { $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1)); return 0; } if (!$cart->checkCoupon()) { $cart->setRabatt(0, 0, 0); JError::raiseWarning("", _JSHOP_RABATT_NON_CORRECT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=cart&task=view', 1, 1)); return 0; } $orderNumber = $jshopConfig->next_order_number; $jshopConfig->updateNextOrderNumber(); $payment_method_id = $cart->getPaymentId(); $pm_method = JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($payment_method_id); $payment_method = $pm_method->payment_class; if ($jshopConfig->without_payment) { $pm_method->payment_type = 1; $paymentSystemVerySimple = 1; } else { $paymentsysdata = $pm_method->getPaymentSystemData(); $payment_system = $paymentsysdata->paymentSystem; if ($paymentsysdata->paymentSystemVerySimple) { $paymentSystemVerySimple = 1; } if ($paymentsysdata->paymentSystemError) { $cart->setPaymentParams(""); JError::raiseWarning("", _JSHOP_ERROR_PAYMENT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step3', 0, 1, $jshopConfig->use_ssl)); return 0; } } $order = JTable::getInstance('order', 'jshop'); $arr_property = $order->getListFieldCopyUserToOrder(); foreach ($adv_user as $key => $value) { if (in_array($key, $arr_property)) { $order->{$key} = $value; } } $sh_mt_pr = JTable::getInstance('shippingMethodPrice', 'jshop'); $sh_mt_pr->load($cart->getShippingPrId()); $order->order_date = $order->order_m_date = getJsDate(); $order->order_tax = $cart->getTax(1, 1, 1); $order->setTaxExt($cart->getTaxExt(1, 1, 1)); $order->order_subtotal = $cart->getPriceProducts(); $order->order_shipping = $cart->getShippingPrice(); $order->order_payment = $cart->getPaymentPrice(); $order->order_discount = $cart->getDiscountShow(); $order->shipping_tax = $cart->getShippingPriceTaxPercent(); $order->setShippingTaxExt($cart->getShippingTaxList()); $order->payment_tax = $cart->getPaymentTaxPercent(); $order->setPaymentTaxExt($cart->getPaymentTaxList()); $order->order_package = $cart->getPackagePrice(); $order->setPackageTaxExt($cart->getPackageTaxList()); $order->order_total = $cart->getSum(1, 1, 1); $order->currency_exchange = $jshopConfig->currency_value; $order->vendor_type = $cart->getVendorType(); $order->vendor_id = $cart->getVendorId(); $order->order_status = $jshopConfig->default_status_order; $order->shipping_method_id = $cart->getShippingId(); $order->payment_method_id = $cart->getPaymentId(); $order->delivery_times_id = $sh_mt_pr->delivery_times_id; if ($jshopConfig->delivery_order_depends_delivery_product) { $order->delivery_time = $cart->getDelivery(); } if ($jshopConfig->show_delivery_date) { $order->delivery_date = $cart->getDeliveryDate(); } $order->coupon_id = $cart->getCouponId(); $pm_params = $cart->getPaymentParams(); if (is_array($pm_params) && !$paymentSystemVerySimple) { $payment_system->setParams($pm_params); $payment_params_names = $payment_system->getDisplayNameParams(); $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params); $order->setPaymentParamsData($pm_params); } $name = $lang->get("name"); $order->ip_address = $_SERVER['REMOTE_ADDR']; $order->order_add_info = JRequest::getVar('order_add_info', ''); $order->currency_code = $jshopConfig->currency_code; $order->currency_code_iso = $jshopConfig->currency_code_iso; $order->order_number = $order->formatOrderNumber($orderNumber); $order->order_hash = md5(time() . $order->order_total . $order->user_id); $order->file_hash = md5(time() . $order->order_total . $order->user_id . "hashfile"); $order->display_price = $jshopConfig->display_price_front_current; $order->lang = $jshopConfig->cur_lang; if ($order->client_type) { $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; } else { $order->client_type_name = ""; } if ($order->order_total == 0) { $pm_method->payment_type = 1; $jshopConfig->without_payment = 1; $order->order_status = $jshopConfig->payment_status_paid; } if ($pm_method->payment_type == 1) { $order->order_created = 1; } else { $order->order_created = 0; } if (!$adv_user->delivery_adress) { $order->copyDeliveryData(); } $dispatcher->trigger('onBeforeCreateOrder', array(&$order)); $order->store(); $dispatcher->trigger('onAfterCreateOrder', array(&$order)); if ($cart->getCouponId()) { $coupon = JTable::getInstance('coupon', 'jshop'); $coupon->load($cart->getCouponId()); if ($coupon->finished_after_used) { $free_discount = $cart->getFreeDiscount(); if ($free_discount > 0) { $coupon->coupon_value = $free_discount / $jshopConfig->currency_value; } else { $coupon->used = $adv_user->user_id; } $coupon->store(); } } $order->saveOrderItem($cart->products); $session->set("jshop_end_order_id", $order->order_id); $order_history = JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $order->order_status; $order_history->status_date_added = $order->order_date; $order_history->customer_notify = 1; $order_history->store(); if ($pm_method->payment_type == 1) { $order->changeProductQTYinStock("-"); if ($jshopConfig->send_order_email) { $checkout->sendOrderEmail($order->order_id); } } $dispatcher->trigger('onEndCheckoutStep5', array(&$order)); $session->set("jshop_send_end_form", 0); if ($jshopConfig->without_payment) { $checkout->setMaxStep(10); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl)); return 0; } $pmconfigs = $pm_method->getConfigs(); $task = "step6"; if (isset($pmconfigs['windowtype']) && $pmconfigs['windowtype'] == 2) { $task = "step6iframe"; $session->set("jsps_iframe_width", $pmconfigs['iframe_width']); $session->set("jsps_iframe_height", $pmconfigs['iframe_height']); } $checkout->setMaxStep(6); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=' . $task, 0, 1, $jshopConfig->use_ssl)); }
function getBuildQueryListProductFilterPrice($filters, &$adv_query, &$adv_from) { if (isset($filters['price_from'])) { $price_from = getCorrectedPriceForQueryFilter($filters['price_from']); } else { $price_from = 0; } if (isset($filters['price_to'])) { $price_to = getCorrectedPriceForQueryFilter($filters['price_to']); } else { $price_to = 0; } if (!$price_from && !$price_to) { return 0; } $jshopConfig = JSFactory::getConfig(); $userShop = JSFactory::getUserShop(); $multyCurrency = count(JSFactory::getAllCurrency()); if ($userShop->percent_discount) { $price_part = 1 - $userShop->percent_discount / 100; } else { $price_part = 1; } $adv_query2 = ""; $adv_from2 = ""; if ($multyCurrency > 1) { $adv_from2 .= " LEFT JOIN `#__jshopping_currencies` AS cr USING (currency_id) "; if ($price_to) { if ($jshopConfig->product_list_show_min_price) { $adv_query2 .= " AND (( prod.product_price*{$price_part} / cr.currency_value )<=" . $price_to . " OR ( prod.min_price*{$price_part} / cr.currency_value)<=" . $price_to . " )"; } else { $adv_query2 .= " AND ( prod.product_price*{$price_part} / cr.currency_value ) <= " . $price_to; } } if ($price_from) { if ($jshopConfig->product_list_show_min_price) { $adv_query2 .= " AND (( prod.product_price*{$price_part} / cr.currency_value ) >= " . $price_from . " OR ( prod.min_price*{$price_part} / cr.currency_value ) >= " . $price_from . " )"; } else { $adv_query2 .= " AND ( prod.product_price*{$price_part} / cr.currency_value ) >= " . $price_from; } } } else { if ($price_to) { if ($jshopConfig->product_list_show_min_price) { $adv_query2 .= " AND (prod.product_price*{$price_part} <=" . $price_to . " OR prod.min_price*{$price_part} <=" . $price_to . " )"; } else { $adv_query2 .= " AND prod.product_price*{$price_part} <= " . $price_to; } } if ($price_from) { if ($jshopConfig->product_list_show_min_price) { $adv_query2 .= " AND (prod.product_price*{$price_part} >= " . $price_from . " OR prod.min_price*{$price_part} >= " . $price_from . " )"; } else { $adv_query2 .= " AND prod.product_price*{$price_part} >= " . $price_from; } } } JPluginHelper::importPlugin('jshoppingproducts'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBuildQueryListProductFilterPrice', array($filters, &$adv_query, &$adv_from, &$adv_query2, &$adv_from2)); $adv_query .= $adv_query2; $adv_from .= $adv_from2; }
public function getList() { /** * Get data */ $db = JFactory::getDBO(); $data = array(); //select from $source = trim($this->_params->get('source', 'js_categories')); if ($source == 'js_categories') { $catids = $this->_params->get('js_categories', ''); } else { if ($this->_params->get('js_ids', '')) { $ids = preg_split('/,/', $this->_params->get('js_ids', '')); $ids_tmp = array(); foreach ($ids as $id) { $ids_tmp[] = (int) trim($id); } } } if ($source == 'js_categories' && $catids && $this->_params->get('limit_items_for_each')) { foreach ($catids as $catid) { $query = $this->buildQuery($catid); $db->setQuery($query); $data = array_merge($data, $db->loadObjectlist()); } } else { if ($source == 'js_categories' && $catids) { $query = $this->buildQuery($catids); $db->setQuery($query); $data = array_merge($data, $db->loadObjectlist()); } else { if ($source == 'js_ids' && $ids_tmp && count($ids_tmp)) { $query = $this->buildQuery(false, $ids_tmp); $db->setQuery($query); $data = array_merge($data, $db->loadObjectlist()); } else { $query = $this->buildQuery(false, false); $db->setQuery($query); $data = array_merge($data, $db->loadObjectlist()); } } } //add link if (!class_exists('JSFactory')) { return null; } $jshopConfig = JSFactory::getConfig(); $userShop = JSFactory::getUserShop(); foreach ($data as $product) { $product->link = SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id=' . $product->category_id . '&product_id=' . $product->id, 1); if ($jshopConfig->show_buy_in_category) { if (!($jshopConfig->hide_buy_not_avaible_stock && $product->product_quantity <= 0)) { $product->add_to_cart = '<a class="bt-addtocart" href="' . SEFLink('index.php?option=com_jshopping&controller=cart&task=add&category_id=' . $product->category_id . '&product_id=' . $product->id, 1) . '" title="' . sprintf(JText::_('ADD_PRODUCT_TO_CART'), $product->name) . '">' . JText::_('ADD_TO_CART') . '</a>'; } } if ($jshopConfig->image_product_live_path) { $product->thumbnail = $jshopConfig->image_product_live_path . '/' . $product->thumbnail; } $product->category_link = SEFLink('index.php?option=com_jshopping&controller=category&task=view&category_id=' . $product->category_id, 1); //calculate price $product->product_price = getPriceFromCurrency($product->product_price, $product->currency_id); $product->product_old_price = getPriceFromCurrency($product->product_old_price, $product->currency_id); $product->product_price = getPriceCalcParamsTax($product->product_price, $product->product_tax_id); $product->product_old_price = getPriceCalcParamsTax($product->product_old_price, $product->product_tax_id); if ($userShop->percent_discount) { $product->product_price = getPriceDiscount($product->product_price, $userShop->percent_discount); $product->product_old_price = getPriceDiscount($product->product_old_price, $userShop->percent_discount); } $product->old_price = ''; if ($product->product_old_price) { $product->old_price = formatprice($product->product_old_price); } if ($product->product_price) { $product->sales_price = formatprice($product->product_price); } // title cut $titleMaxChars = $this->_params->get('title_max_chars', '100'); $limit_title_by = $this->_params->get('limit_title_by', 'char'); $replacer = $this->_params->get('replacer', '...'); $isStrips = $this->_params->get("auto_strip_tags", 1); $stringtags = ''; if ($limit_title_by == 'word' && $titleMaxChars > 0) { $product->name_cut = self::substrword($product->name, $titleMaxChars, $replacer, $isStrips); } elseif ($limit_title_by == 'char' && $titleMaxChars > 0) { $product->name_cut = self::substring($product->name, $titleMaxChars, $replacer, $isStrips); } } if (empty($data)) { return array(); } /** * Get display and config params */ /* title */ $isStrips = $this->_params->get("auto_strip_tags", 1); $stringtags = ''; if ($isStrips) { $allow_tags = $this->_params->get("allow_tags", ''); $stringtags = ''; if (!is_array($allow_tags)) { $allow_tags = explode(',', $allow_tags); } foreach ($allow_tags as $tag) { $stringtags .= '<' . $tag . '>'; } } if (!$this->_params->get('default_thumb', 1)) { $this->_defaultThumb = ''; } /* intro */ $maxDesciption = $this->_params->get('description_max_chars', 100); $limitDescriptionBy = $this->_params->get('limit_description_by', 'char'); $isThumb = $this->_params->get('image_thumb', 1); $dateFormat = $this->_params->get('date_format', 'DATE_FORMAT_LC3'); foreach ($data as $key => &$product) { if ($this->_params->get('show_date')) { $product->date = JHtml::_('date', $product->created_on, JText::_($dateFormat)); } if ($this->_params->get('show_intro')) { if ($limitDescriptionBy == 'word') { $product->description = self::substrword($product->introtext, $maxDesciption, $stringtags); } else { $product->description = self::substring($product->introtext, $maxDesciption, $stringtags); } } //if show image if ($this->_params->get('show_image')) { $product->thumbnail = explode(',', $product->thumbnail); $thumbnail = ''; foreach ($product->thumbnail as $tmpThumbnail) { $type = explode('.', $tmpThumbnail); $type = strtolower($type[count($type) - 1]); if (in_array($type, array('jpg', 'jpeg', 'png', 'png'))) { $thumbnail = $tmpThumbnail; break; } } $product->thumbnail = $thumbnail; $product = $this->generateImages($product, $isThumb); } //get label $product->label_image = $product->label_image ? $jshopConfig->image_labels_live_path . "/" . $product->label_image : ''; if ($this->_params->get('show_manufacturer')) { $product->manufacturer_link = SEFLink('index.php?option=com_jshopping&controller=manufacturer&task=view&manufacturer_id=' . $product->product_manufacturer_id); } } if ($this->_params->get('show_rating')) { foreach ($data as $key => &$product) { $count = floor($jshopConfig->max_mark / $jshopConfig->rating_starparts); $width = $count * 16; $rating = round($product->rating); $product->ratingSpan = '<span class="vote">'; if (empty($rating)) { $product->ratingSpan .= '<span style="width: ' . $width . 'px;" title="' . JText::_("RATING_UNRATE") . '" class="ratingbox" style="display:inline-block;">'; } else { $width_active = intval($rating * 16 / $jshopConfig->rating_starparts); $product->ratingSpan .= '<span style="width: ' . $width . 'px;" title="' . JText::_("RATING") . ' ' . $rating . '/' . $jshopConfig->max_mark . '" class="ratingbox" style="display:inline-block;">'; $product->ratingSpan .= '<span class="ratingactive" style="width: ' . $width_active . 'px"></span>'; } $product->ratingSpan .= '</span></span>'; } } return $data; }
function getBuildSelectAttributes($attributeValues, $attributeActive, $displayonlyattrtype = null) { $jshopConfig = JSFactory::getConfig(); if (!$jshopConfig->admin_show_attributes) { return array(); } $dispatcher = JDispatcher::getInstance(); $attrib = JSFactory::getAllAttributes(); $userShop = JSFactory::getUserShop(); $selects = array(); foreach ($attrib as $k => $v) { $attr_id = $v->attr_id; if ($displayonlyattrtype) { $v->attr_type = $displayonlyattrtype; } if (isset($attributeValues[$attr_id]) && $attributeValues[$attr_id]) { if (isset($attributeActive[$attr_id])) { $_firstval = $attributeActive[$attr_id]; } else { $_firstval = 0; } $selects[$attr_id] = new stdClass(); $selects[$attr_id]->attr_id = $attr_id; $selects[$attr_id]->attr_name = $v->name; $selects[$attr_id]->attr_description = $v->description; $selects[$attr_id]->groupname = $v->groupname; $selects[$attr_id]->firstval = $_firstval; $options = $attributeValues[$attr_id]; $attrimage = array(); foreach ($options as $k2 => $v2) { $attrimage[$v2->val_id] = $v2->image; $addPrice = $v2->addprice; $addPrice = getPriceFromCurrency($addPrice, $this->currency_id); $addPrice = getPriceCalcParamsTax($addPrice, $this->product_tax_id); if ($userShop->percent_discount) { $addPrice = getPriceDiscount($addPrice, $userShop->percent_discount); } $options[$k2]->addprice = $addPrice; } if ($v->attr_type == 1) { // attribut type select if ($jshopConfig->attr_display_addprice) { foreach ($options as $k2 => $v2) { if (($v2->price_mod == "+" || $v2->price_mod == "-" || $jshopConfig->attr_display_addprice_all_sign) && $v2->addprice > 0) { $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice, null, 0, -1) . ")"; $options[$k2]->value_name .= $ext_price_info; } } } if ($jshopConfig->product_attribut_first_value_empty) { $first = array(); $first[] = JHTML::_('select.option', '0', _JSHOP_SELECT, 'val_id', 'value_name'); $options = array_merge($first, $options); } if (isset($attributeActive[$attr_id]) && isset($attrimage[$attributeActive[$attr_id]])) { $_active_image = $attrimage[$attributeActive[$attr_id]]; } else { $_active_image = ''; } if (isset($attributeActive[$attr_id])) { $_select_active = $attributeActive[$attr_id]; } else { $_select_active = ''; } $html_select_attribute_param = 'class="' . $jshopConfig->frontend_attribute_select_class_css . '" size = "' . $jshopConfig->frontend_attribute_select_size . '" onchange="setAttrValue(\'' . $attr_id . '\', this.value);"'; $selects[$attr_id]->selects = JHTML::_('select.genericlist', $options, 'jshop_attr_id[' . $attr_id . ']', $html_select_attribute_param, 'val_id', 'value_name', $_select_active) . "<span class='prod_attr_img'>" . $this->getHtmlDisplayProdAttrImg($attr_id, $_active_image) . "</span>"; $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects); } else { // attribut type radio foreach ($options as $k2 => $v2) { if ($v2->image) { $options[$k2]->value_name = "<img src='" . $jshopConfig->image_attributes_live_path . "/" . $v2->image . "' alt='' /> " . $v2->value_name; } } if ($jshopConfig->attr_display_addprice) { foreach ($options as $k2 => $v2) { if (($v2->price_mod == "+" || $v2->price_mod == "-" || $jshopConfig->attr_display_addprice_all_sign) && $v2->addprice > 0) { $ext_price_info = " (" . $v2->price_mod . formatprice($v2->addprice) . ")"; $options[$k2]->value_name .= $ext_price_info; } } } $radioseparator = ''; if ($jshopConfig->radio_attr_value_vertical) { $radioseparator = "<br/>"; } foreach ($options as $k2 => $v2) { $options[$k2]->value_name = "<span class='radio_attr_label'>" . $v2->value_name . "</span>"; } $selects[$attr_id]->selects = sprintRadioList($options, 'jshop_attr_id[' . $attr_id . ']', 'onclick="setAttrValue(\'' . $attr_id . '\', this.value);"', 'val_id', 'value_name', $attributeActive[$attr_id], $radioseparator); $selects[$attr_id]->selects = str_replace(array("\n", "\r", "\t"), "", $selects[$attr_id]->selects); } $dispatcher->trigger('onBuildSelectAttribute', array(&$attributeValues, &$attributeActive, &$selects, &$options, &$attr_id, &$v)); } } $grname = ''; foreach ($selects as $k => $v) { if ($v->groupname != $grname) { $grname = $v->groupname; $selects[$k]->grshow = 1; } else { $selects[$k]->grshow = 0; } } return $selects; }
public static function getAllTaxes() { static $rows; if (!is_array($rows)) { $jshopConfig = JSFactory::getConfig(); $dispatcher = JDispatcher::getInstance(); $_tax = JSFactory::getTable('tax', 'jshop'); $rows = JSFactory::getAllTaxesOriginal(); if ($jshopConfig->use_extend_tax_rule) { $country_id = 0; $adv_user = JSFactory::getUserShop(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; if (!$country_id) { $adv_user = JSFactory::getUserShopGuest(); $country_id = $adv_user->country; if ($jshopConfig->tax_on_delivery_address && $adv_user->delivery_adress && $adv_user->d_country) { $country_id = $adv_user->d_country; } $client_type = $adv_user->client_type; $enter_tax_id = $adv_user->tax_number != ""; } if ($country_id) { $_rowsext = $_tax->getExtTaxes(); $dispatcher->trigger('beforeGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); foreach ($_rowsext as $v) { if (in_array($country_id, $v->countries)) { if ($jshopConfig->ext_tax_rule_for == 1) { if ($enter_tax_id) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } else { if ($client_type == 2) { $rows[$v->tax_id] = $v->firma_tax; } else { $rows[$v->tax_id] = $v->tax; } } } } $dispatcher->trigger('afterGetAllTaxesRowsext', array(&$_rowsext, &$country_id, &$adv_user, &$rows)); unset($_rowsext); } } $dispatcher->trigger('afterGetAllTaxes', array(&$rows)); } return $rows; }
function step5save(){ $mainframe =& JFactory::getApplication(); $this->_check(5); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher =& JDispatcher::getInstance(); $lang = &JSFactory::getLang(); $user = &JFactory::getUser(); if ($user->id){ $adv_user = &JSFactory::getUserShop(); }else{ $adv_user = &JSFactory::getUserShopGuest(); } $cart = &JModel::getInstance('cart', 'jshop'); $cart->load(); $cart->setDisplayItem(1, 1); $cart->setDisplayFreeAttributes(); $session =& JFactory::getSession(); $jshopConfig = &JSFactory::getConfig(); $orderNumber = $jshopConfig->next_order_number; $jshopConfig->updateNextOrderNumber(); $db = &JFactory::getDBO(); $payment_method_id = $cart->getPaymentId(); $pm_method = &JTable::getInstance('paymentMethod', 'jshop'); $pm_method->load($payment_method_id); $payment_method = $pm_method->payment_class; if ($jshopConfig->without_payment){ $pm_method->payment_type = 1; $paymentSystemVerySimple = 1; }elseif (!file_exists($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method. '.php')) { $paymentSystemVerySimple = 1; }else{ $paymentSystemVerySimple = 0; include_once ($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method . '.php'); if (!class_exists($payment_method)) { $cart->setPaymentParams(""); JError::raiseWarning("",_JSHOP_ERROR_PAYMENT); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step3',0,1,$jshopConfig->use_ssl)); return 0; } } $order = &JTable::getInstance('order', 'jshop'); $arr_property = array('user_id','f_name','l_name','firma_name','client_type','firma_code','tax_number','email','street','zip','city','state','country','phone','mobil_phone','fax','title','ext_field_1','ext_field_2','ext_field_3','d_f_name','d_l_name','d_firma_name','d_email','d_street','d_zip','d_city','d_state','d_country','d_phone','d_mobil_phone','d_title','d_fax','d_ext_field_1','d_ext_field_2','d_ext_field_3'); foreach ($adv_user as $key => $value) { if(in_array($key, $arr_property)) { $order->$key = $value; } } $order->order_date = $order->order_m_date = date("Y-m-d H:i:s", mktime()); $order->order_tax = $cart->getTax(1, 1, 1); $order->setTaxExt($cart->getTaxExt(1, 1, 1)); $order->order_subtotal = $cart->getPriceProducts(); $order->order_shipping = $cart->getShippingPrice(); $order->order_payment = $cart->getPaymentPrice(); $order->order_discount = $cart->getDiscountShow(); $order->order_total = $cart->getSum(1, 1, 1); $order->currency_exchange = $jshopConfig->currency_value; $order->vendor_type = $cart->getVendorType(); $order->vendor_id = $cart->getVendorId(); $order->order_status = $jshopConfig->default_status_order; $order->shipping_method_id = $cart->getShippingId(); $order->payment_method_id = $cart->getPaymentId(); $pm_params = $cart->getPaymentParams(); if (is_array($pm_params) && !$paymentSystemVerySimple) { $payment_system = new $payment_method(); $payment_system->setParams($pm_params); $payment_params_names = $payment_system->getDisplayNameParams(); $order->payment_params = getTextNameArrayValue($payment_params_names, $pm_params); $order->setPaymentParamsData($pm_params); } $name = $lang->get("name"); $order->ip_address = $_SERVER['REMOTE_ADDR']; $order->order_add_info = JRequest::getVar('order_add_info',''); $order->currency_code = $jshopConfig->currency_code; $order->currency_code_iso = $jshopConfig->currency_code_iso; $order->order_number = $order->formatOrderNumber($orderNumber); $order->order_hash = md5(time().$order->order_total.$order->user_id); $order->file_hash = md5(time().$order->order_total.$order->user_id."hashfile"); $order->display_price = $jshopConfig->display_price_front_current; $order->lang = $jshopConfig->cur_lang; if ($order->client_type){ $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type]; }else{ $order->client_type_name = ""; } if ($pm_method->payment_type == 1){ $order->order_created = 1; }else { $order->order_created = 0; } if (!$adv_user->delivery_adress) $order->copyDeliveryData(); $dispatcher->trigger( 'onBeforeCreateOrder', array(&$order) ); if (!$order->store()){ JError::raiseWarning("", $order->getError()); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5',0,1,$jshopConfig->use_ssl)); return 0; } $dispatcher->trigger( 'onAfterCreateOrder', array(&$order) ); if ($cart->getCouponId()){ $coupon = &JTable::getInstance('coupon', 'jshop'); $coupon->load($cart->getCouponId()); if ($coupon->finished_after_used){ $free_discount = $cart->getFreeDiscount(); if ($free_discount > 0){ $coupon->coupon_value = $free_discount / $jshopConfig->currency_value; }else{ $coupon->used = $adv_user->user_id; } $coupon->store(); } } $order->saveOrderItem($cart->products); $session->set("jshop_end_order_id", $order->order_id); $order_history = &JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $order->order_status; $order_history->status_date_added = $order->order_date; $order_history->customer_notify = 1; $order_history->store(); if ($pm_method->payment_type == 1){ $order->changeProductQTYinStock("-"); } if ($pm_method->payment_type == 1){ $this->_sendOrderEmail($order->order_id); } $dispatcher->trigger( 'onEndCheckoutStep5', array(&$order) ); $session->set("jshop_send_end_form", 0); if ($jshopConfig->without_payment) { $this->_setMaxStep(10); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl)); return 0; } $this->_setMaxStep(6); $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step6',0,1,$jshopConfig->use_ssl)); }
<?php /** * @version $Id: mod_login.php 14401 2010-01-26 14:10:00Z louis $ * @package Joomla * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); error_reporting(error_reporting() & ~E_NOTICE); if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_jshopping' . DS . 'jshopping.php')) { JError::raiseError(500, "Please install component \"joomshopping\""); } require_once JPATH_SITE . DS . 'components' . DS . 'com_jshopping' . DS . "lib" . DS . "factory.php"; require_once JPATH_SITE . DS . 'components' . DS . 'com_jshopping' . DS . "lib" . DS . "functions.php"; JSFactory::loadCssFiles(); JSFactory::loadLanguageFile(); // Include the syndicate functions only once require_once dirname(__FILE__) . DS . 'helper.php'; $params->def('greeting', 1); $type = modulLoginHelper::getType(); $return = modulLoginHelper::getReturnURL($params, $type); $user = JSFactory::getUserShop(); require JModuleHelper::getLayoutPath('mod_jshopping_login');
function myaccount() { $jshopConfig = JSFactory::getConfig(); checkUserLogin(); $adv_user = JSFactory::getUserShop(); $adv_user->prepareUserPrint(); JshopHelpersMetadata::userMyaccount(); $config_fields = $jshopConfig->getListFieldsRegisterType('editaccount'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeDisplayMyAccount', array(&$adv_user, &$config_fields)); $view = $this->getView('user'); $view->setLayout("myaccount"); $view->assign('config', $jshopConfig); $view->assign('user', $adv_user); $view->assign('config_fields', $config_fields); $view->assign('href_user_group_info', SEFLink('index.php?option=com_jshopping&controller=user&task=groupsinfo')); $view->assign('href_edit_data', SEFLink('index.php?option=com_jshopping&controller=user&task=editaccount', 0, 0, $jshopConfig->use_ssl)); $view->assign('href_show_orders', SEFLink('index.php?option=com_jshopping&controller=user&task=orders', 0, 0, $jshopConfig->use_ssl)); $view->assign('href_logout', SEFLink('index.php?option=com_jshopping&controller=user&task=logout')); $dispatcher->trigger('onBeforeDisplayMyAccountView', array(&$view)); $view->display(); }
function updateOtherPricesIncludeAllFactors() { $jshopConfig = JSFactory::getConfig(); $userShop = JSFactory::getUserShop(); $this->product_old_price = $this->getOldPrice(); $this->product_old_price = getPriceFromCurrency($this->product_old_price, $this->currency_id); $this->product_old_price = getPriceDiscount($this->product_old_price, $userShop->percent_discount); $this->product_old_price = getPriceCalcParamsTax($this->product_old_price, $this->product_tax_id); if (is_array($this->product_add_prices)) { foreach ($this->product_add_prices as $key => $value) { $this->product_add_prices[$key]->price = getPriceFromCurrency($this->product_add_prices[$key]->price, $this->currency_id); $this->product_add_prices[$key]->price = getPriceDiscount($this->product_add_prices[$key]->price, $userShop->percent_discount); $this->product_add_prices[$key]->price = getPriceCalcParamsTax($this->product_add_prices[$key]->price, $this->product_tax_id); } } JPluginHelper::importPlugin('jshoppingproducts'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('updateOtherPricesIncludeAllFactors', array(&$this)); }
/** * Update jshopping user info */ private function jshoppingUpdateUserInfo() { $adv_user = JSFactory::getUserShop(); if ($adv_user->user_id <= 0) { $adv_user = JSFactory::getUserShopGuest(); } if ($adv_user->title == 1) { $this->userGender = 'male'; } else { if ($adv_user->title == 2) { $this->userGender = 'female'; } } if (!empty($adv_user->f_name)) { $this->userFirstName = $adv_user->f_name; } if (!empty($adv_user->l_name)) { $this->userLastName = $adv_user->l_name; } if (!empty($adv_user->email)) { $this->userEmail = $adv_user->email; } if (!empty($adv_user->phone)) { $this->userPhone = $adv_user->phone; } if (!empty($adv_user->birthday)) { $this->userDateOfBirth = $adv_user->birthday; } }