コード例 #1
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function display($tpl = null)
 {
     if (!isset($this->context) || $this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if (!$this->context->controller->isInitialized()) {
         $this->context->controller->initialize();
     }
     $app = JFactory::getApplication();
     $useSSL = isset($this->context->controller->ssl_enabled) && $this->context->conteoller->ssl_enabled && $app->input->get('enable_ssl') || JeproshopTools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     /*$contextParams = $this->context->controller->getContextParams();
       foreach ($contextParams as $assign_key => $assign_value){
           if (!is_array($assign_value) && mb_substr($assign_value, 0, 1, 'utf-8') == '/' || $protocol_content == 'https://'){
               $this->assignRef($assign_key, $protocol_content.JeproshopTools::getMediaServer($assign_value).$assign_value);
           }else{
               $this->assignRef($assign_key, $assign_value);
           }
       }*/
     if (!isset(self::$cache_products)) {
         $category = new JeproshopCategoryModelCategory(JeproshopContext::getContext()->shop->getCategoryId(), (int) JeproshopContext::getContext()->language->lang_id);
         $nb = (int) JeproshopSettingModelSetting::getValue('number_of_products_on_page');
         self::$cache_products = JeproshopDefaultModelDefault::getProducts((int) JeproshopContext::getContext()->language->lang_id, 0, $nb ? $nb : 8, 'position');
     }
     if (self::$cache_products === false || empty(self::$cache_products)) {
         self::$cache_products = false;
     }
     $this->assignRef('products', self::$cache_products);
     $display_add_product = JeproshopSettingModelSetting::getValue('display_category_attribute');
     $this->assignRef('display_add_product', $display_add_product);
     $homeSize = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('home'));
     $this->assignRef('homeSize', $homeSize);
     $this->assignRef('pagination', JeproshopDefaultModelDefault::$_pagination);
     parent::display($tpl);
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function assignSummaryInformations()
 {
     $context = JeproshopContext::getContext();
     $summary = $context->cart->getSummaryDetails();
     $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas($context->cart->cart_id);
     // override customization tax rate with real tax (tax rules)
     if ($customizedDatas) {
         foreach ($summary['products'] as &$productUpdate) {
             $productId = (int) (isset($productUpdate->product_id) ? $productUpdate->product_id : $productUpdate->product_id);
             $productAttributeId = (int) (isset($productUpdate->product_attribute_id) ? $productUpdate->product_attribute_id : $productUpdate->product_attribute_id);
             if (isset($customizedDatas[$productId][$productAttributeId])) {
                 $productUpdate->tax_rate = JeproshopTaxModelTax::getProductTaxRate($productId, $context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
             }
         }
         JeproshopProductModelProduct::addCustomizationPrice($summary->products, $customizedDatas);
     }
     $cart_product_context = JeproshopContext::getContext()->cloneContext();
     foreach ($summary['products'] as $key => $product) {
         $product->quantity = $product->cart_quantity;
         // for compatibility with 1.2 themes
         if ($cart_product_context->shop->shop_id != $product->shop_id) {
             $cart_product_context->shop = new JeproshopModelShop((int) $product->shop_id);
         }
         $null = null;
         $product->price_without_specific_price = JeproshopProductModelProduct::getStaticPrice($product->product_id, !JeproshopProductModelProduct::getTaxCalculationMethod(), $product->product_attribute_id, 2, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context);
         if (JeproshopProductModelProduct::getTaxCalculationMethod()) {
             $product->is_discounted = $product->price_without_specific_price != $product->price;
         } else {
             $product->is_discounted = $product->price_without_specific_price != $product->price_wt;
         }
     }
     // Get available cart rules and unset the cart rules already in the cart
     $available_cart_rules = JeproshopCartRuleModelCartRule::getCustomerCartRules($this->context->language->lang_id, isset($this->context->customer->customer_id) ? $this->context->customer->customer_id : 0, true, true, true, $this->context->cart);
     $cart_cart_rules = $context->cart->getCartRules();
     foreach ($available_cart_rules as $key => $available_cart_rule) {
         if (!$available_cart_rule->high_light || strpos($available_cart_rule->code, 'BO_ORDER_') === 0) {
             unset($available_cart_rules[$key]);
             continue;
         }
         foreach ($cart_cart_rules as $cart_cart_rule) {
             if ($available_cart_rule->cart_rule_id == $cart_cart_rule->cart_rule_id) {
                 unset($available_cart_rules[$key]);
                 continue 2;
             }
         }
     }
     $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && JeproshopSettingModelSetting::getValue('ship_when_available');
     $this->assign($summary);
     //$this->assign('token_cart', Tools::getToken(false));
     $this->assign('is_logged', $this->context->controller->isLogged);
     $this->assign('is_virtual_cart', $this->context->cart->isVirtualCart());
     $this->assign('product_number', $this->context->cart->numberOfProducts());
     $this->assign('voucher_allowed', JeproshopCartRuleModelCartRule::isFeaturePublished());
     $this->assign('shipping_cost', $this->context->cart->getOrderTotal(true, JeproshopCartModelCart::ONLY_SHIPPING));
     $this->assign('shipping_cost_tax_excluded', $this->context->cart->getOrderTotal(false, JeproshopCartModelCart::ONLY_SHIPPING));
     $this->assign('customizedDatas', $customizedDatas);
     $this->assign('CUSTOMIZE_FILE', JeproshopProductModelProduct::CUSTOMIZE_FILE);
     $this->assign('CUSTOMIZE_TEXT_FIELD', JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD);
     $this->assign('last_product_added', $this->context->cart->getLastProduct());
     $this->assign('display_vouchers', $available_cart_rules);
     $this->assign('currency_sign', $this->context->currency->sign);
     $this->assign('currency_rate', $this->context->currency->conversion_rate);
     $this->assign('currency_format', $this->context->currency->format);
     $this->assign('currency_blank', $this->context->currency->blank);
     $this->assign('show_option_allow_separate_package', $show_option_allow_separate_package);
     $this->assign('small_size', JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('small')));
     /*
             $this->context->smarty->assign(array(
                 'HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary),
                 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)
             ));*/
 }
コード例 #3
0
ファイル: image.php プロジェクト: jeprodev/jeproshop
 /**
  * Returns the path to the folder containing the image in the new filesystem
  *
  * @return string path to folder
  */
 public function getImageFolder()
 {
     if (!$this->image_id) {
         return false;
     }
     if (!$this->folder) {
         $this->folder = JeproshopImageModelImage::getStaticImageFolder($this->image_id);
     }
     return $this->folder;
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 /**
  * Assign template vars related to images
  */
 protected function assignImages()
 {
     $app = JFactory::getApplication();
     $images = $this->product->getImages((int) $this->context->cookie->lang_id);
     $product_images = array();
     if (isset($images[0])) {
         $this->assignRef('mainImage', $images[0]);
     }
     foreach ($images as $image) {
         if ($image->cover) {
             $this->assignRef('mainImage', $image);
             $cover = $image;
             $cover->image_id = JeproshopSettingModelSetting::getValue('legacy_images') ? $this->product->product_id . '_' . $image->image_id : $image->image_id;
             $cover->only_image_id = (int) $image->image_id;
         }
         $product_images[(int) $image->image_id] = $image;
     }
     if (!isset($cover)) {
         if (isset($images[0])) {
             $cover = $images[0];
             $cover->image_id = JeproshopSettingModelSetting::getValue('legacy_images') ? $this->product->product_id . '-' . $images[0]->image_id : $images[0]->image_id;
             $cover->only_image_id = (int) $images[0]->image_id;
         } else {
             $cover = new JObject();
             $cover->image_id = $this->context->language->iso_code . '_default';
             $cover->legend = JText::_('COM_JEPROSHOP_NO_PICTURE_LABEL');
             $cover->title = JText::_('COM_JEPROSHOP_NO_PICTURE_LABEL');
         }
     }
     $size = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('large'));
     $has_image = isset($cover->image_id) && (int) $cover->image_id ? array((int) $cover->image_id) : JeproshopProductModelProduct::getCover((int) $app->input->get('product_id'));
     $this->assignRef('has_image', $has_image);
     $this->assignRef('cover', $cover);
     $width = (int) $size->width;
     $this->assignRef('image_width', $width);
     $medium_size = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('medium'));
     $this->assignRef('medium_size', $medium_size);
     $large_size = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('large'));
     $this->assignRef('large_size', $large_size);
     $home_size = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('home'));
     $this->assignRef('home_size', $home_size);
     $cart_size = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('cart'));
     $this->assignRef('cart_size', $cart_size);
     //$this->assignRef('col_img_dir', _PS_COL_IMG_DIR_));
     if (count($product_images)) {
         $this->assignRef('images', $product_images);
     }
 }
コード例 #5
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderView($tpl = null)
 {
     if (!$this->loadObject(true)) {
         return;
     }
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $customer = new JeproshopCustomerModelCustomer($this->cart->customer_id);
     $currency = new JeproshopCurrencyModelCurrency($this->cart->currency_id);
     $this->context->cart = $this->cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     //$this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->cart_id);
     $products = $this->cart->getProducts();
     $customized_datas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $this->cart->cart_id);
     JeproshopProductModelProduct::addCustomizationPrice($products, $customized_datas);
     $summary = $this->cart->getSummaryDetails();
     /* Display order information */
     $order_id = (int) JeproshopOrderModelOrder::getOrderIdByCartId($this->cart->cart_id);
     $order = new JeproshopOrderModelOrder($order_id);
     if (JeproshopTools::isLoadedObject($order, 'order_id')) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $shop_id = (int) $order->shop_id;
     } else {
         $shop_id = (int) $this->cart->shop_id;
         $tax_calculation_method = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
     }
     if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
         $total_products = $summary->total_products;
         $total_discounts = $summary->total_discounts_tax_exc;
         $total_wrapping = $summary->total_wrapping_tax_exc;
         $total_price = $summary->total_price_without_tax;
         $total_shipping = $summary->total_shipping_tax_exc;
     } else {
         $total_products = $summary->total_products_wt;
         $total_discounts = $summary->total_discounts;
         $total_wrapping = $summary->total_wrapping;
         $total_price = $summary->total_price;
         $total_shipping = $summary->total_shipping;
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
             $product->product_price = $product->price;
             $product->product_total = $product->total;
         } else {
             $product->product_price = $product->price_wt;
             $product->product_total = $product->total_wt;
         }
         $image = array();
         $db = JFactory::getDBO();
         if (isset($product->product_attribute_id) && (int) $product->product_attribute_id) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_image') . " WHERE product_attribute_id = " . (int) $product->product_attribute_id;
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         if (!isset($image->image_id)) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product->product_id . " AND cover = 1 ";
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         $product_obj = new JeproshopProductModelProduct($product->product_id);
         $product->qty_in_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, isset($product->product_attribute_id) ? $product->product_attribute_id : null, (int) $shop_id);
         $image_product = new JeproshopImageModelImage($image->image_id);
         $product->image = isset($image->image_id) ? JeproshopImageManager::thumbnail(COM_JEPROSHOP_IMAGE_DIR . 'products/' . $image_product->getExistingImagePath() . '.jpg', 'product_mini_' . (int) $product->product_id . (isset($product->product_attribute_id) ? '_' . (int) $product->product_attribute_id : '') . '.jpg', 45, 'jpg') : '--';
     }
     /*$helper = new HelperKpi();
       $helper->id = 'box-kpi-cart';
       $helper->icon = 'icon-shopping-cart';
       $helper->color = 'color1';
       $helper->title = $this->l('Total Cart', null, null, false);
       $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
       $helper->value = Tools::displayPrice($total_price, $currency);
       $kpi = $helper->generate(); */
     //$this->assignRef('kpi', $kpi);
     $this->assignRef('products', $products);
     $discounts = $this->cart->getCartRules();
     $this->assignRef('discounts', $discounts);
     $this->assignRef('order', $order);
     $this->assignRef('currency', $currency);
     $this->assignRef('customer', $customer);
     $customerStats = $customer->getStats();
     $this->assignRef('customer_stats', $customerStats);
     $this->assignRef('total_products', $total_products);
     $this->assignRef('total_discounts', $total_discounts);
     $this->assignRef('total_wrapping', $total_wrapping);
     $this->assignRef('total_price', $total_price);
     $this->assignRef('total_shipping', $total_shipping);
     $this->assignRef('customized_datas', $customized_datas);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 private function initAttributesForm()
 {
     if (!JeproshopCombinationModelCombination::isFeaturePublished()) {
         $settingPanelLink = '<a href="#" >' . JText::_('COM_JEPROSHOP_PERFORMANCE_LABEL') . '</a>';
         JError::raiseWarning(500, JText::_('COM_JEPROSHOP_FEATURE_HAS_BEEN_DISABLED_MESSAGE') . $settingPanelLink);
     } elseif (JeproshopTools::isLoadedObject($this->product, 'product_id')) {
         if ($this->product_exists_in_shop) {
             if ($this->product->is_virtual) {
                 JError:
                 raiseWarning(500, JText::_('COM_JEPROSHOP_VIRTUAL_PRODUCT_CANNOT_HAVE_COMBINATIONS'));
             } else {
                 $attribute_js = array();
                 $attributes = JeproshopAttributeModelAttribute::getAttributes($this->context->language->lang_id, true);
                 if ($attributes) {
                     foreach ($attributes as $key => $attribute) {
                         $attribute_js[$attribute->attribute_group_id][$attribute->attribute_id] = $attribute->name;
                     }
                 }
                 $this->assignRef('attributeJs', $attribute_js);
                 $attributes_groups = JeproshopAttributeGroupModelAttributeGroup::getAttributesGroups($this->context->language->lang_id);
                 $this->assignRef('attributes_groups', $attributes_groups);
                 $images = JeproshopImageModelImage::getImages($this->context->language->lang_id, $this->product->product_id);
                 $weight_unit = JeproshopSettingModelSetting::getValue('weight_unit');
                 $this->assignRef('weight_unit', $weight_unit);
                 $reasons = JeproshopStockMovementReasonModelStockMovementReason::getStockMovementReasons();
                 $this->assignRef('reasons', $reasons);
                 //$this->assignRef('minimal_quantity', );
                 $this->assignRef('available_date', $available_date);
                 $stock_mvt_default_reason = JeproshopSettingModelSetting::getValue('default_stock_mvt_reason');
                 $this->assignRef('default_stock_mvt_reason', $stock_mvt_default_reason);
                 $i = 0;
                 /*$type = JeproshopImageTypeModelImageType::getByNameNType('%', 'products', 'height');
                   if (isset($type->name)){
                       $data->assign('imageType', $type['name']);
                   }else
                       $data->assign('imageType', 'small_default'); */
                 //$this->assignRef('imageWidth', (isset($image_type->width) ? (int)($image_type->width) : 64) + 25);
                 foreach ($images as $k => $image) {
                     $images[$k]->obj = new JeproshopImageModelImage($image->image_id);
                     ++$i;
                 }
                 $this->assignRef('attribute_images', $images);
                 $attributeList = $this->renderAttributesList($this->product, $this->currency);
                 $this->assignRef('list', $attributeList);
                 $combination_exists = JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getContextShopGroup()->share_stock && count(JeproshopAttributeGroupModelAttributeGroup::getAttributesGroups($this->context->language->lang_id)) > 0 && $this->product->hasAttributes();
                 $this->assignRef('combination_exists', $combination_exists);
             }
         }
     }
 }
コード例 #7
0
ファイル: product.php プロジェクト: jeprodev/jeproshop
 /**
  * Delete product images from database
  *
  * @return bool success
  */
 public function deleteImages()
 {
     $db = JFactory::getDBO();
     $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $this->product_id;
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $status = true;
     if ($result) {
         foreach ($result as $row) {
             $image = new JeproshopImageModelImage($row->image_id);
             $status &= $image->delete();
         }
     }
     return $status;
 }
コード例 #8
0
ファイル: controller.php プロジェクト: jeprodev/jeproshop
 /**
  * Returns a link to a product image for display
  * Note: the new image filesystem stores product images in subdirectories of img/p/
  *
  * @param string $name rewrite link of the image
  * @param string $ids id part of the image filename - can be "id_product-id_image" (legacy support, recommended) or "id_image" (new)
  * @param string $type
  * @return string
  */
 public function getImageLink($name, $ids, $type = null)
 {
     $not_default = false;
     if (is_array($name)) {
         $name = $name[JeproshopContext::getContext()->language->lang_id];
     }
     // legacy mode or default image
     $theme = JeproshopShopModelShop::isFeaturePublished() && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . $ids . ($type ? '_' . $type : '') . '_' . (int) JeproshopContext::getContext()->shop->theme_id . '.jpg') ? '_' . JeproshopContext::getContext()->shop->theme_id : '';
     if (JeproshopSettingModelSetting::getValue('legacy_images') && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . $ids . ($type ? '-' . $type : '') . $theme . '.jpg') || ($not_default = strpos($ids, 'default') !== false)) {
         if ($this->allow_link_rewrite == 1 && !$not_default) {
             echo $name;
             $uri_path = JURI::base() . $ids . ($type ? '_' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = JURI::base() . 'components/com_jeproshop/assets/themes/' . $ids . ($type ? '_' . $type : '') . $theme . '.jpg';
         }
     } else {
         // if ids if of the form product_id-id_image, we want to extract the id_image part
         $split_ids = explode('_', $ids);
         $image_id = isset($split_ids[1]) ? $split_ids[1] : $split_ids[0];
         $theme = JeproshopShopModelShop::isFeaturePublished() && file_exists(COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . JeproshopImageModelImage::getStaticImageFolder($image_id) . $image_id . ($type ? '_' . $type : '') . '_' . (int) JeproshopContext::getContext()->shop->theme_id . '.jpg') ? '_' . JeproshopContext::getContext()->shop->theme_id : '';
         if ($this->allow_link_rewrite == 1) {
             $uri_path = JURI::base() . $image_id . ($type ? '_' . $type : '') . $theme . '/' . $name . '.jpg';
         } else {
             $uri_path = JURI::base() . COM_JEPROSHOP_PRODUCT_IMAGE_DIRECTORY . JeproshopImageModelImage::getStaticImageFolder($image_id) . $image_id . ($type ? '_' . $type : '') . $theme . '.jpg';
         }
     }
     //return JeproshopTools::getMediaServer($uri_path).$uri_path;
     return $uri_path;
 }