prestashop,prestashop-1.6 , New module for personal collection/receive with possibility to choose shop (pickup to store)


New module for personal collection/receive with possibility to choose shop (pickup to store)

Question:

Tag: prestashop,prestashop-1.6

I want to add possibility for clients to receive orders personally in one of our shops. I tried to find some module which gives possibility to select in which shop they want to receive order but I haven't found anything for free. Because of that I want to create new module for it. What's more I'm totally new in prestashop and I don't know where to start or how to create this module. I spend two-three days reading how to do it and these are my assumptions:

  1. New carrier module can be created by extending CarrierModule class.
  2. I read some articles / documentation about hooks.
  3. I have created my first carrier module by editing module attached in this article http://www.prestashop.com/blog/en/carrier_modules_functions_creation_and_configuration/.
  4. What I achieved is that I installed module and used hook 'BeforeCarrier' to add some layout to page after selecting my carrier.

This is how my carrier should work:

  1. It should be a part of carrier list so customer is able to select it.
  2. If carrier is not selected nothing hapens. If carrier is selected by customer then button 'Choose shop' should be shown.
  3. After pressing button 'Choose shop' new window should be show with addresses of our shops (instead of new window it may be placed somewhere in current page).
  4. Window with shop adresses will contain list of addresses with radiobuttons and button to confirm selection.
  5. After confirmation of selection window will be closed and address should be shown as a part of carreir.
  6. E-mail with confirmation will contain information in which shop customer can collect order.
  7. Suppose that addresses will be hardcoded in php code.

These are my questions:

  1. I created new carrier module so I assume it works correctly (as described here http://www.prestashop.com/blog/en/carrier_modules_functions_creation_and_configuration/).
  2. How to add new button 'Choose shop' near selected carrier?
  3. Can I use hooks to add 'Choose shop' button?
  4. Where should I remember choosen shop address? Has 'Carrier' class place for it?
  5. How to add shop address to e-mails? Should I edit layouts? Does e-mail layout contain place for it or do I need to add new 'placeholder' for it?
  6. How to show chosen address on admin side?

To describe my problem more detail I have created few scenario (see attachment). I will be greatful for any help.

I've posted the same question on prestashop forum.


Answer:
  1. These example are usually old and poorly written. They lack structure. But for your purpose I suppose they're ok.
  2. Use hookDisplayCarrierList($args). Check $args to see which carrier has been selected, then return <select> element which you shop addresses. This hook is triggered every time a user selects a carrier and is return via Ajax. Therefore, you may not use ajax here.

    You should include you javascript in a file. Use hookDisplayHeader to detect when to insert this file into your page:

    public function hookDisplayHeader(){
    
    $propExists = property_exists($this->context->controller, 'php_self');
    
    if($propExists){
    
        $controllerName = $this->context->controller->php_self;
        if(in_array($controllerName, array('order', 'order-opc'))){
    
         // $this->context->controller->addJS($this->_path.'js/customcarrier.js');
    

    This Javascript file should check whether a valid shop has been selected before going to the next step;

    Because your Js code is in a file and the hookDisplayCarrierList cannot contain any JavaScript (because it returns Ajax),

    you should also make use of hookDisplayBeforeCarrier. Here you could insert you custom carrier ID - this way you'd know when to check for errors with your JS file.

  3. Same question as #2.

  4. The correct way to save the information would be to add a model. CustomCarrierSelectedAddress - or something like it. It would have these columns: id_cart, id_shop_address;

    The way you implement shop addresses is up to you. You may define them as constants or even make a new model for them.

    Models arent that hard to create, you just need to declare class properties, static variable $definition that's it.

    You may add you own methods. You should also add createTable()/dropTable() methods for convenience.

  5. This is more complicated. You could:

    There should be an array of email placeholders and their values, which the controllers assigns.

    for example '{order_id}'. You should add your email variable to array {chosen_shop_info} and assign whole paragraph of text to it. Then you may use it in the actual email template which you can edit in BO.

    This is more or less the only way I know to edit the existing templates, because you can't do conditional statements inside email templates.

  6. To add chosen address to order page in BO, you should use another hook - hookDisplayAdminOrder. here you can add your own block to be display in order summary.

To find out which hooks are available, go to Hook.php and look for method exec(). Add this line error_log($hook_name). When you perform a specific action, executed hooks will be logged and you will see what kind of hook you need.


Related:


How to add another row in Best Seller items in prestashop


prestashop-1.6
I'll like to add another row of 4 best items on my home page under "LOS MAS VENDIDOS", how can I do it?

AH01630: client denied by server configuration Apache


linux,apache,.htaccess,prestashop,prestashop-1.6
I get this error when trying to access localhost via a browser. 403 Forbidden I use Ubuntu 14.04 LTS Here is my configuration file: etc/apache2.conf # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions. # See http://httpd.apache.org/docs/2.4/ for...

Prestashop changes to theme


prestashop
I am totally new to Prestashop, I have only just looked at the dashboard today for the first time. I have been tasked with making a small design change (CSS) to a Prestashop site that used an off the shelf theme. I know in WordPress you can make a child...

CMS Editor not working


html,css,content-management-system,editor,prestashop-1.6
I have created a cms page with a table in it. I am trying to put a border around my table but it does not show the border in the front end. I can see the border appear when i edit the page but not on the actual site. I...

PRESTASHOP1.6 Display categories block on product.tpl page


php,prestashop
My category block appeared fine on the left column on category page. But when I clicked on single product page, the category block is gone. I tried many things the last 2 days, it still won't show up. I tried to transplant the module to displayLeftColumnProduct (I assumed this is...

Can I override a scss style in Prestashop?


css,sass,prestashop
I'm using a default theme in Prestashop 1.6 and I have a problem. What I'm trying to accomplish is to simply move the navbar 25px higher. I know that I need to remove or change #block_top_menu { padding-top: 25px; } in blocktopmenu.scss, which is located not in the modules directory,...

Prestashop select attribute combination photos


prestashop,prestashop-1.6
Short version : I want to get product photos that are assigned to product's attribute groups. Long version : I want to accomplish the feature by creating a custom module : on product page, you can choose a product color by choosing from a list of product's photos representing different...

Adding new table in rest api of prestashop webservice


php,web-services,rest,prestashop
I've been successful in creating an extra table in the prestashop products table throught rest api of webservice , however the api link http://127.0.0.1/prestashop/api/wb3d/1 wb3d is the new table which I have created in webservice . Which holds a path to an images directory somewhere on the web . This...

import image in Prestashop with a website URL


csv,prestashop
I have a website on which my all products are display and all product images are save on this website server. my new website making in prestashop on another server. I have a csv file which make according to prestashop. in this csv file images fill like : http://example.net/images/demo.jpg Like...

Prestashop HelperFrom/List - messy layout


forms,list,prestashop,helpers
I'm new to prestashop and I worked the whole day on creating a back office interface that allows the user to write, edit, and delete articles. It is sort of a blog. I used Prestashop's Helpers (Form and List) and everything works great. I also added a new tab in...

Prestashop remove the call us info header


templates,header,task-parallel-library,prestashop
In which module and tpl file I can delete the "call us" info and number phone that appear in the Header template I'm using? Using Prestashop 1.6...

Prestashop 1.6 - Add custom field to category


php,prestashop,prestashop-1.6
I would like to know how I can add a custom field to a category and how I can edit in the back office (under the description field). the field I would like to add is name description_long The field type is TEXT I already have overwritten my Front office...

prestashop a new product with features and images through a module


php,prestashop
Product information successfully added besides features and image. Here is my code: $product = new Product(); $image = new Image(); $langId = (int) (Configuration::get('PS_LANG_DEFAULT')); $name = Tools::getValue('pr_name'); $product->id_supplier = $arr['pr_supp'][0]; $product->id_manufacturer = Tools::getValue('pr_manuf'); $product->description_short = Tools::getValue('pr_short_desc'); $product->description = Tools::getValue('pr_desc'); $product->quantity = Tools::getValue('pr_cant'); $product->name = array($langId =>...

How prevent PrestaShop from updating product quantities after order validation


php,sql,prestashop-1.6,prestashop-1.5
I am new to prestashop and I am trying to make a payment module where I need to duplicate an order for statistical issues. My problem is that the duplicate order also substracts from product stock and I need to know where, after an order validation, does prestashop update stock...

Using translation with jquery in prestashop


javascript,jquery,smarty,prestashop
I'm trying to translate some terms when I'm using jQuery inside a smarty file. This is my jQuery code: else { $("#message").val("{l s='Please try to be clear.'}"); This phrase appears exactly as {l s='Please try to be clear.'} in my web page and doesn't take into consideration the translation mode....

How does prestashop display modules


php,prestashop
my quest is to swap position of 2 modules in left column. I read that normally I should do this in administration panel -> live edit The problem is that prestashop used by this web was little bit edited, some modules were deleted, so live edit does not work. In...

prestashop: adding a product to cart, with custom fields


php,module,prestashop,cart
Good day all. I'm developing a module for prestashop, in which the user choose some settings, and then it is possible to save these settings and add a custom product to cart, using them as values for custom fields. I've added a new product, with 7 custom text fields. then...

Structure table of prestashop


prestashop
Do you know which table I can find users purchases (with its id) and the id of the producers? I'm trying but your help would speed my work....

prestashop 1.4 to 1.6 image missing issue


prestashop,prestashop-1.6
I've upgraded a Prestashop site manually from 1.4 to 1.6.I can get the category images to appear but not the product images. My product path on the old 1.4 site takes the following route .../img/p/11-638-home.jpg but version 1.6 is asking for Original image is missing or empty (/.../.../../img/p/1/1.jpg) for product...

Prestashop 1.6 product_list: get number of attached attribute combinations


php,e-commerce,prestashop
I'm building my first prestashop. I have a couple of products with attribute combinations that have an impact on the price. In list views, I would like to detect if a product has more than one combination attached to it, in order to display a 'from' before the price. I...

REST service from Cordova with WAMP (local)


cordova,rest,prestashop
I am trying to extract products in a web service (prepared by my PrestaShop website), using WAMP (in local so). My code : index.js var app = { initialize: function() { this.bindEvents(); }, bindEvents: function() { this.onDeviceReady(); }, onDeviceReady: function() { var password = ''; var key = 'F51Q7VWPRREG7TA25DEY8UIZT8V79E5V'; var...

Native Mobile app for presta shop [closed]


php,android,e-commerce,prestashop-1.6
I want to develop a native android application for my PrestaShop store. I have been searching on Google for a while but all i found was third party applications that says they can create an application for mobile. The documentation doesn't provide a clear answer as well. Does prestashop provide...

Prestashop custom php file with query


php,include,connection,prestashop,require
I am new to prestashop and I have made a custom php file which is called by ajax and has SQL queries. The problem is that this file doesn't have a connection. What should I include or require in it to achieve it?

prestashop add extra tab to product management with some angular


jquery,angularjs,prestashop
I'm trying to add functionalities to prestashop product management system. With a simple module called Advprod. Using displayAdminProductsExtra hook I was able to add section to product management in prestashop backoffice. In this new section I've to work with angular. My actual tpl is correctly loaded by an ajax request...

Return to previous page and refresh it in php?


php,prestashop-1.6
I have a submit form and while submitting the form it will load a php for the process like insert to DB and all.For going back to the submit form I added header("location:javascript://history.go(-1)"); But how to reload the page (the submit form page so user can see the submitted form...

Custom upload file on Prestashop page


php,file-upload,prestashop
I made a separate page (following this guide) so he can upload pdf files (certificates of their products). And another page to the customer's search according to the selected product. On the file upload page, the logic is as follows: In a form: Select the product (from a selector), and...

Prestashop Cart Summary : Custom code is disabled when quantities added


cart,prestashop-1.6
I modified the shopping-cart-product-line.tpl, so that it displays the product price with and without tax in the cart summary. With Tax : price=$product.price_wt Without Tax : price=$product.price <li class="price priceDark{if isset($product.is_discounted) && $product.is_discounted && isset($product.reduction_applies) && $product.reduction_applies} special-price{/if}">{convertPrice price=$product.price_wt} TTC</li> <li class="price{if isset($product.is_discounted) && $product.is_discounted...

Prestashop 1.6 display custom field in Feature Add/Edit form


php,smarty,e-commerce,prestashop,prestashop-1.6
I am able to display my custom field in Feature Value Add/Edit form by overriding AdminFeaturesController and overriding initFormFeatureValue() function. I want to do the same for Feature Add/Edit form but cannot find function to override. I tried renderForm() function but didn't work. Which file/class/controller/function should I look into to...

prestashop search by category and quantity of products


prestashop
I only reached: $results = $db->executeS(' SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_product` cp '.(Group::isFeatureActive() ? 'INNER JOIN `'._DB_PREFIX_.'category_group` cg ON cp.`id_category` = cg.`id_category`' : '').' INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category` INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product` '.Shop::addSqlAssociation('product', 'p', false).' WHERE c.`active` = 1 AND product_shop.`active` = 1...

How to disable module hooks for certain controllers in Prestashop?


php,prestashop
I'm writing my own module and the essential option is to control controller from the module options. I know how to control tpl and js via module options but I can't get the way to control Prestashop controller from the module php file. Simply I want to know the way...

delphi XE8 REST Interface PUT in prestashop


rest,delphi,prestashop
I'm trying to update a manufacturer in Prestashop through the REST interface. So far I've been able to GET the information, but when I try to PUT, I Always get an HTTP 500 error. try Memo1.Text := '<prestashop><manufacturer><id><![CDATA[804]]></id><name><![CDATA[DisneyLand]]></name></manufacturer></prestashop>'; RESTRequest1.Params.Clear; //authentication does not work with PUT, use token as suffix.... RESTClient1.Authenticator...

All Payment Modules in Prestasop Not Displaying


module,prestashop,payment,prestashop-1.6
please help me None of my payment modules are being displayed on the final checkout page . I have installed and configured the following modules correctly payment by cheque Bank Wire Cash on delivery. Payu (payment gateway like paypal ) All the above worked fine until past month when they...

Prestashop 1.6 Module error: Notice on line 719 in file prestashop16\tools\smarty\sysplugins\smarty_internal_templatebase.php


php,smarty,e-commerce,prestashop,prestashop-1.6
I'm developing a module and extended AdminFeaturesController.php to display my custom field Add/Edit Feature Value, but it is showing following error in popup: Notice on line 719 in file D:\xampp\htdocs\prestashop16\tools\smarty\sysplugins\smarty_internal_templatebase.php(157) : eval()'d code [8] Undefined index: value I think it is due to I override the function initFormFeatureValue() in my...

Prestashop 1.6 : Display a line TotalProductsTaxes in order-detail.tpl


order,prestashop,prestashop-1.6
I want to display a Total Taxes line in the Order-Detail.tpl I added that line of code but I don't know what to write to get TotalProductsTaxes instead of TotalProductsWithoutTaxes. I tried several things but they all broke the page. <tr class="item"> <td colspan="{if $return_allowed}2{else}1{/if}"> <strong>{l s='TVA :'}</strong> </td> <td...

Update product from a module in prestashop


php,mysql,prestashop
I have to update the price and quantity values of specific products in a database. As I understand, simply executing sql commands is not a great option since there are a lot of tables which have similar informations. I have read that Product() object should be created. How should I...

Prestashop - Add multiple category trees with helper form


php,prestashop,prestashop-1.6
I'm creating a prestashop module which need to select 2 categories root. I tried to add 2 fields with type "categories", but on the second category tree, it has the same ID and the same NAME as the first tree. $fields_form[1]['form'] = array( 'legend' => array( 'title' => $this->l('Setting'), ),...

Getting javascript var from database record in Smarty


javascript,jquery,smarty,prestashop
I'm working on a PrestaShop page with the file extension ".tpl". I get the javascript code to auto complete like this: var currencies = [ { value: 'Afghan afghani', data: 'AFN' }, { value: 'Albanian lek', data: 'ALL' }, { value: 'Algerian dinar', data: 'DZD' }, { value: 'European euro',...

Add AJAX loader gif in prestashop


ajax,prestashop
I have two questions regarding prestashop. 1) How do I add an ajax loader image in prestashop for an ajax call? 2) Can I add an AJAX loader image to every ajax call in prestashop by placing some code in one place? I am new to prestashop, so pardon my...

How to create a page in a prestashop module such that the output is not wrapped in the site's template html AND using translation?


module,controller,prestashop
What I know to do: 1) Create a module controller that allows translation. I can declare texts to translate either in the controller itself or in the template: /modules/mymodule/controllers/front/list.php class myModuleListModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->l('Some text to translater'); $this->setTemplate('list.tpl'); } } /modules/mymodule/views/templates/front/list.tpl {l s='Some other...

Split best seller and new arrivals in prestashop


css,prestashop,prestashop-1.6
I'll like to split best seller and new arrival blocks in two rows. So there is a title with "NUEVOS" with the new arrivals products then below a title again "LOS MAS VENDIDOS" with the best seller items (removing the "tabs", just titles) Thanks you very much...