Jump to content


  • Posts

  • Joined

  • Last visited

About Zhivko

  • Birthday 01/01/1

Zhivko's Achievements


Newbie (1/14)



  1. Hi, I can't find a way how to stop ordering process if multiple products are selected and there is no common carrier for them. I have the following configuration: PrestaShop Product1 can be shipped by Carrier1 Product2 can be shipped by Carrier2 If a customer selects Product1 and Product2 in the same cart PS creates two orders for the same cart. I want to disallow this process and to show and error on the shipping page. Is it possible to be configured or I have to do a code modification?
  2. 1. OrderInvoice class is located in /classes/order/OrderInvoice.php Add some code to extract product short description to getProducts result. Example: put this code in function getProducts after $row['id_address_delivery'] = $order->id_address_delivery; $sql = SELECT `description_short` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$row['id_product']; $row['product_desc_short'] = Db::getInstance()->getValue($sql); 2. Invoice template is located in /pdf/invoice.tpl Add some code to display product short description. Example: modify the product name display: <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> Add product short description in the same cell of the table, under the name <td style="text-align: left; width: 45%">{$order_detail.product_name}</br>{$order_detail.product_desc_short}</td>
  3. Hi, Thanks for your comment. I added a $(document).ready at the beginning of JS and I use solution 1. It didn't solve my problem but I found the reason for incorrect calculation. It appears that different SQL date formats are handled in IE and non-IE Date object. My date is "2013-04-30 00:00:00" and IE does not support this format. http://stackoverflow.com/questions/3243546/problem-with-javascript-date-function-in-ie-7-returns-nan Therefore I added a small piece of code to convert SQL date to Date object: var tstr = priceExpiryDate; //Convert SQL date from string to JS Date object tstr = tstr.replace(/:| /g,"-"); var YMDhms = tstr.split("-"); var sqlDate = new Date(); sqlDate.setFullYear(parseInt(YMDhms[0]), parseInt(YMDhms[1])-1, parseInt(YMDhms[2])); sqlDate.setHours(parseInt(YMDhms[3]), parseInt(YMDhms[4]), parseInt(YMDhms[5]), 0/*msValue*/); left = Math.floor((sqlDate - (new Date())) / 1000); Now it works fine with all browsers, except for CSS in IE 9.0 which is a new story
  4. I'm trying to implement a countdown module which uses a JS to display remaining special price time. 1) In module.php file I read $special_price->to value and assign it to smarty array $this->context->smarty->assign(array( 'expiry' => $specific_price->to, )); test 1: After reading a lot of topics in various forums and sites I tried to pass it as a global variable In module.tpl file I want to pass 'expiry' value to JS class <script type="text/javascript"> var priceExpiryDate = "{$expiry}"; </script> In js class I use it to initialize counter var ts = new Date(priceExpiryDate); left = Math.floor((ts - (new Date())) / 1000); This solution works fine with Chrome but it doesn't work with Firefox and IE. I tried to set global variable using alert("{$expiry}") and it doesn't work - it just opens a pop-up message in IE. test 2: In module.tpl file I set 'expiry value to a hiddent <span> <span id="expiry_date" style="display:none">{$expiry}</span> In js class I try to read it using var ts = $('#expiry_date').text() or var ts = $('#expiry_date').val() In both text() and val() cases date is not retreived from html. I tried <span class="expiry_date" style="display:none">{$expiry}</span> and var ts = $('span.expiry_date').text() and it doesn't work, too. What am I doing wrong?
  5. You may define a new function in OrderInvoice class to retrieve product short description. See function getProducts - you have order detail information as $row => you may call your function using $row['id_product'] (and product_attribute_id) and retrieve it's short description using SQL. Then it might be assigned to $row['product_short_desc']. You will use this information in invoice.tpl somewhere in {foreach $order_details as $order_detail}, it will be {$order_detail.product_short_desc} Honestly, I didn't test it but it should work like that. PDF variables are collected in HTMLTemplateInvoice.php, 'order_details' => $this->order_invoice->getProducts()
  6. Described solution is for module Block Categories only. It works fine with and single store. The SQL request should be extended to manage multiple stores: $ProductsCount = (int)Db::getInstance()->getValue('SELECT COUNT(cp.`id_product`) AS total FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product` WHERE cp.`id_category` = '.$id_category. ' AND product_shop.`visibility` IN ("both", "catalog") AND product_shop.`active` = 1;' ); If you need to display total number of products per sub-category after you selected a category, then you have to update Categories controller. Note the following row in function assignProductList: $this->nbProducts = $this->category->getProducts(null, null, null, $this->orderBy, $this->orderWay, true); It retrieves number of products per selected category. Now you may update CategorController function assignSubcategories to collect number of products per subcategory using the same function: foreach ($subCategories as $key => $subcat) { $subcategoryObj = new Category((int)$subcat['id_category']); $subCategories[$key]['nb_products'] = $subcategoryObj->getProducts(null, null, null, null, null, true); } In category.tpl you should add the following code to display number of products after name: ({$subcategory.nb_products}) after {$subcategory.name|escape:'htmlall':'UTF-8'} BTW, it's nice to have a separate static function to collect number of products without details in Categories class, i.e. to call the SQL request above without creating an instance and reading all useless product details.
  7. My last idea is to check products - if correct carriers are selected for products in the cart. If you created carriers after products, they might be unselected.
  8. Did you choose shipping method for both carriers = Price? On Carrier details screen it is a radio button with label 'Billing:' and value 'According to total price'
  9. There is no screen-shot for defined price ranges and weight ranges. Did you set this information about your carriers?
  10. Hi, I fixed this by adding a validation of available quantities to PaymentModule.php public function validateOrder $this->context->cart = new Cart($id_cart); //START: added code to check avilable quantities if (!$this->context->cart->checkQuantities()) { Tools::displayError('An item in your cart is no longer available in this quantity, you cannot proceed with your order.'); return false; } //END $this->context->customer = new Customer($this->context->cart->id_customer); Regards, Zhivko
  11. Hi, I'm trying to add a new Monitoring option to Catalog -> Monitoring screen. The goal is to display all products with Specific Price end date defined. I override AdminTrackingController.php in /override/controllers/admin by defining a new function public function getCustomListSpecialPrices() { if (!Configuration::get('PS_STOCK_MANAGEMENT')) return; $this->table = 'product'; $this->lang = true; $this->identifier = 'id_product'; $this->_orderBy = 'id_product'; $this->_orderWay = 'ASC'; $this->className = 'Product'; $this->_list_index = 'index.php?controller=AdminProducts'; $this->_list_token = Tools::getAdminTokenLite('AdminProducts'); $this->show_toolbar = false; $this->addRowAction('edit'); $this->addRowAction('delete'); $this->fields_list = array( 'id_product' => array('title' => $this->l('ID'), 'width' => 50), 'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name'), 'specific_end' => array('title' => $this->l('Specific Price End')), 'active' => array('title' => $this->l('Status'), 'type' => 'bool', 'active' => 'status', 'width' => 50) ); $this->clearFilters(); $this->_select = 'user_alias.`to` AS specific_end'; $this->_join = $this->_join = Shop::addSqlAssociation('product', 'a'). ' LEFT JOIN `'._DB_PREFIX_.'specific_price` user_alias ON (a.`id_product` = user_alias.`id_product`)'; $this->_filter = 'AND user_alias.`to` IS NOT NULL'; $this->tpl_list_vars = array('sub_title' => $this->l('List of products with stored special price end date:')); return $this->renderList(); } I need to add a _select clause in order to retrieve Specific Price end date and display it in the result list. There are two issues with this: 1. $this->_select = 'user_alias.`to` AS specific_end'; the same select clause is added to core functions SQL requests thus causing an SQL error. Example: SELECT SQL_CALC_FOUND_ROWS b.*, a.* , user_alias.`to` AS specific_end FROM `ps_category` a LEFT JOIN `ps_category_lang` b ON (b.`id_category` = a.`id_category` AND b.`id_lang` = 1 AND b.`id_shop` = 1) INNER JOIN ps_category_shop category_shop ON (category_shop.id_category = a.id_category AND category_shop.id_shop = 1) WHERE 1 AND a.`id_category` NOT IN ( SELECT DISTINCT(cp.id_category) FROM `ps_category_product` cp ) AND a.`id_category` != 1 ORDER BY name desc LIMIT 0,50 Workaround: I solved this by adding $this->_select = false; to all core AdminTrackingController functions and in AdminController.php I added a check (isset($this->_select) ? ', '.$this->_select : '') becomes ((isset($this->_select) && $this->_select != false) ? ', '.$this->_select : '') 2. When a sort by filter is selected the same sort order is applied to all results. Example: if I select to sort by product name "List of products with attributes and without available quantities for sale:" => the same sort criteria is applied to all product related lists. The problem: either after I succeed to display Specific Price end date it is not possible to sort results by this filter. This sort order will trigger SQL errors in 'order by' clause for all other lists. Workaround: 'specific_end' field can be defined as 'orderby' => false to avoid ordering 3. The same pb appears if results are filtered by this field: there is a SQL error in WHERE clause Workaround: 'specific_end' field can be defined as 'search' => false to avoid filtering Please advise how these issues can be solved in a proper way.
  12. Hi, I found the same issue in PrestaShop v1.5.2. In my case the reason was sort order set in Preferences -> Products -> Pagination -> Default order by: if I select sort by 'Product added date' the list of products for a supplier is empty. It seems like a bug in Supplier.php, function getProducts: $alias is not managed if $order_by='date_add'. Regards, Zhivko
  13. Hi, Look at the third post in this topic. Rush says: You have to prepare a definition file for your prefered font and encoding and place it in /tools/fpdf/fonts folder. PS: You need definition files for regular and bold font type. PDF invoice uses both. For ex. times and timesb.
  14. Hi, Open file /classes/PDF.php and find the row $this->Image(_PS_IMG_DIR_.'/logo.jpg', 10, 8, 0, 15); _PS_IMG_DIR_ is the path to the image (/img folder). '/logo.jpg' is the name of the image. You may store your invoice logo to /img folder and name it inv_logo.jpg. In this case the code should be: $this->Image(_PS_IMG_DIR_.'/inv_logo.jpg', 10, 8, 0, 15);
  15. Hi, To manage PDF encoding/font settings I added a new tab 'PDF Invoice' (look at the screenshot) and added a pdf icon called 44.gif (44 is the id of the new tab) to /img/t folder. Here are the new modifications to the files: 1. New file /admin/tabs/AdminPDF.php - allows encoding and font management in BackOffice -> Preferences -> PDF Invoice tab. Encoding is set to configuration table as PS_PDF_ENCODING_{language} for the current language . Font is set to configuration table as PS_PDF_FONT_{language} for the current language . 2. Modified /classes/PDF.php - read configuration from database 3. Modified /admin/tabs/AdminTranslations.php - copy pdf translations when copying a language. All modifications are markeed with //ZKOEV v2 Regards, Zhivko PDF.php AdminPDF.php AdminTranslations.php
  • Create New...