PrestaShop | universal open-source software platform | Ecommerce library

 by   PrestaShop PHP Version: 8.0.2 License: Non-SPDX

kandi X-RAY | PrestaShop Summary

PrestaShop is a PHP library typically used in Web Site, Ecommerce, Nodejs applications. PrestaShop has no bugs, it has no vulnerabilities and it has medium support. However PrestaShop has a Non-SPDX License. You can download it from GitHub.
PrestaShop is an Open Source e-commerce web application, committed to providing the best shopping cart experience for both merchants and customers. It is written in PHP, is highly customizable, supports all the major payment services, is translated in many languages and localized for many countries, has a fully responsive design (both front and back office), etc. See all the available features. This repository contains the source code of PrestaShop, which is intended for development and preview only. To download the latest stable public version of PrestaShop (currently, version 1.7), please go to the download page on the official PrestaShop site.
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        PrestaShop has a medium active ecosystem.
                        summary
                        It has 7077 star(s) with 4578 fork(s). There are 465 watchers for this library.
                        summary
                        There were 6 major release(s) in the last 6 months.
                        summary
                        There are 2486 open issues and 11066 have been closed. On average issues are closed in 54 days. There are 177 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of PrestaShop is 8.0.2
                        PrestaShop Support
                          Best in #Ecommerce
                            Average in #Ecommerce
                            PrestaShop Support
                              Best in #Ecommerce
                                Average in #Ecommerce

                                  kandi-Quality Quality

                                    summary
                                    PrestaShop has 0 bugs and 0 code smells.
                                    PrestaShop Quality
                                      Best in #Ecommerce
                                        Average in #Ecommerce
                                        PrestaShop Quality
                                          Best in #Ecommerce
                                            Average in #Ecommerce

                                              kandi-Security Security

                                                summary
                                                PrestaShop has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                PrestaShop code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                PrestaShop Security
                                                  Best in #Ecommerce
                                                    Average in #Ecommerce
                                                    PrestaShop Security
                                                      Best in #Ecommerce
                                                        Average in #Ecommerce

                                                          kandi-License License

                                                            summary
                                                            PrestaShop has a Non-SPDX License.
                                                            summary
                                                            Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
                                                            PrestaShop License
                                                              Best in #Ecommerce
                                                                Average in #Ecommerce
                                                                PrestaShop License
                                                                  Best in #Ecommerce
                                                                    Average in #Ecommerce

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        PrestaShop releases are available to install and integrate.
                                                                        summary
                                                                        Installation instructions, examples and code snippets are available.
                                                                        summary
                                                                        It has 1740682 lines of code, 22790 functions and 9247 files.
                                                                        summary
                                                                        It has medium code complexity. Code complexity directly impacts maintainability of the code.
                                                                        PrestaShop Reuse
                                                                          Best in #Ecommerce
                                                                            Average in #Ecommerce
                                                                            PrestaShop Reuse
                                                                              Best in #Ecommerce
                                                                                Average in #Ecommerce
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi has reviewed PrestaShop and discovered the below as its top functions. This is intended to give you an instant insight into PrestaShop implemented functionality, and help decide if they suit your requirements.
                                                                                  • Import one product
                                                                                    • Validate an order
                                                                                      • Sends an email .
                                                                                        • Show Kpi
                                                                                          • Change order state
                                                                                            • Returns the neutral value for a cart item .
                                                                                              • Remove a product .
                                                                                                • Map LocaleData to a LocaleData object .
                                                                                                  • Return the shipping cost for the package .
                                                                                                    • Initialize form back
                                                                                                      Get all kandi verified functions for this library.
                                                                                                      Get all kandi verified functions for this library.

                                                                                                      PrestaShop Key Features

                                                                                                      PrestaShop is the universal open-source software platform to build your e-commerce solution.

                                                                                                      PrestaShop Examples and Code Snippets

                                                                                                      No Code Snippets are available at this moment for PrestaShop.
                                                                                                      Community Discussions

                                                                                                      Trending Discussions on PrestaShop

                                                                                                      Display Data from database table of module to Prestashop Product Page - Prestashop 1.7.7.6
                                                                                                      chevron right
                                                                                                      Prestashop updateCategories() inconsistent times, works almost instantly sometimes and sometimes it slows to a crawl
                                                                                                      chevron right
                                                                                                      IFNULL doesn't works my_sql
                                                                                                      chevron right
                                                                                                      How can I access Configuration::get('PS_LAST_QTIES') at core.js?
                                                                                                      chevron right
                                                                                                      Prestashop module with Symfony cant find the controller
                                                                                                      chevron right
                                                                                                      Prestashop: Get parent category informations from the sub-category page
                                                                                                      chevron right
                                                                                                      Days to update Error 400: redirect_uri_mismatch?
                                                                                                      chevron right
                                                                                                      How check if new function is working on prestashop
                                                                                                      chevron right
                                                                                                      Access Prestashop cookies from JavaScript
                                                                                                      chevron right
                                                                                                      Why does *ngIf seem to break my reactive form? How do I handle conditional Inputs and validation in Angular?
                                                                                                      chevron right

                                                                                                      QUESTION

                                                                                                      Display Data from database table of module to Prestashop Product Page - Prestashop 1.7.7.6
                                                                                                      Asked 2022-Apr-03 at 17:03

                                                                                                      I find in internet a CRUD module (create, read, update, delete) and it works very well in backoffice of Prestashop 1.7.7.6

                                                                                                      And now I want to select data from module table and display in front office prestashop product page tpl file

                                                                                                      How can i do ?

                                                                                                      please help me

                                                                                                      Thanks You very much in advance

                                                                                                      structure of crud module moduletest :

                                                                                                      - Classes / Moduletesttabletest.php
                                                                                                      - Controllers / Admin / Adminmoduletest.php
                                                                                                      - moduletest.php
                                                                                                      

                                                                                                      Display Data from database table of module to Prestashop Product Page - Prestashop 1.7.7.6

                                                                                                      ANSWER

                                                                                                      Answered 2022-Apr-03 at 17:03

                                                                                                      You need to select hook there data will be displayed

                                                                                                      Than add this hook to your moduletest.php file in two places.
                                                                                                      For example to show data on product page near price block you can use hook ProductPriceBlock

                                                                                                      1. There is public function install() in yor module. It will register hook, so prestashop knows that it`s function need to be called

                                                                                                        public function install()
                                                                                                       {    ....
                                                                                                           $this->registerHook('header') &&
                                                                                                           $this->registerHook('backOfficeHeader') &&
                                                                                                         ++$this->registerHook('displayProductPriceBlock');
                                                                                                       }
                                                                                                      
                                                                                                    • At the end of file before closing code block "}" add code to retrive and display data to according function:

                                                                                                    •  public function hookdisplayProductPriceBlock($params)
                                                                                                       {    //     your code goes here         }
                                                                                                      
                                                                                                      1. Reset module in modules Modules manager - this will actualy register hook after you make changes to source code

                                                                                                      2. To use template you need according tpl file in /views/templates/front/ subdirectory of module and call it by

                                                                                                       $this->display(__FILE__, 'my-template.tpl');
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/71725143

                                                                                                      QUESTION

                                                                                                      Prestashop updateCategories() inconsistent times, works almost instantly sometimes and sometimes it slows to a crawl
                                                                                                      Asked 2022-Mar-22 at 10:50

                                                                                                      Has anyone had any issue with using Prestashop's Product class updateCategories() before for updating lots of products categories at once? We're using this to map supplier categories to our own categories and we need to change 100's-1000's of products categories. The problem we're running into is that updateCategories usually slows down to a crawl when updating larger amounts of products 100+ and will take hours to do it.

                                                                                                      I've checked the timings of it running on 50 products and sometimes it updates them fine and sometimes it starts slowing down immensely after 30-40.

                                                                                                      One other thread suggested it might be an action hook triggering on updateCategories(), but even after disabling / overriding the modules with this hook (ps_mainmenu, ps_facetedsearch) it still didn't fix it.

                                                                                                      Our shop currently has ~150 000 products and 300+ categories, the server hardware shouldn't be a problem, checked the metrics and nothing was bottlenecking it.

                                                                                                      Would love to hear any suggestions on where the problem could be originating from, or a way to find out what's causing it myself.

                                                                                                      Attaching an example script for bulk updating categories.

                                                                                                      $productIds = Db::getInstance()->executeS('SELECT id_product FROM `' . _DB_PREFIX_ . 'product` ORDER BY id_product LIMIT 60');
                                                                                                      $categoryId = 1;
                                                                                                      $time_pre_total = microtime(true);
                                                                                                      foreach ($productIds as $id) {
                                                                                                        echo '------------------------------------------';
                                                                                                        var_dump($id);
                                                                                                        echo '
                                                                                                      '; $time_pre = microtime(true); $product = new Product((int)$id['id_product'], null, null, (int)Context::getContext()->shop->id); $time_post = microtime(true); $exec_time = $time_post - $time_pre; var_dump($exec_time); echo '
                                                                                                      '; $time_pre = microtime(true); $product->updateCategories([(int)$categoryId]); $time_post = microtime(true); $exec_time = $time_post - $time_pre; var_dump($exec_time); echo '
                                                                                                      '; $time_pre = microtime(true); $product->id_category_default = $categoryId; $time_post = microtime(true); $exec_time = $time_post - $time_pre; var_dump($exec_time); echo '
                                                                                                      '; $time_pre = microtime(true); $product->update(); $time_post = microtime(true); $exec_time = $time_post - $time_pre; var_dump($exec_time); echo '
                                                                                                      '; echo '------------------------------------------'; } echo '------------------------------------------'; echo '------------------------------------------'; echo '
                                                                                                      '; $time_post_total = microtime(true); $exec_time_total = $time_post_total - $time_pre_total; var_dump($exec_time_total); echo '
                                                                                                      '; echo 'cycle ended';

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-22 at 10:50

                                                                                                      The issue was with the cleanPositions() method in Products class, it was recalculating positions as @user3256843 mentioned in the comments, I'll be looking to override / write a different method for myself to use.

                                                                                                      Source https://stackoverflow.com/questions/71527861

                                                                                                      QUESTION

                                                                                                      IFNULL doesn't works my_sql
                                                                                                      Asked 2022-Mar-22 at 10:24

                                                                                                      I'm trying to get a sql select inside an update, but always return null.

                                                                                                      UPDATE ps_stock_available sa
                                                                                                      SET sa.reserved_quantity = (
                                                                                                          SELECT IFNULL(SUM(od.product_quantity - od.product_quantity_refunded),0) 
                                                                                                          FROM ps_orders o
                                                                                                          INNER JOIN ps_order_detail od ON od.id_order = o.id_order
                                                                                                          INNER JOIN ps_order_state os ON os.id_order_state = o.current_state
                                                                                                          WHERE o.id_shop = 1 AND
                                                                                                          os.shipped != 1 AND (
                                                                                                              o.valid = 1 OR (
                                                                                                                  os.id_order_state NOT IN ('6,28,59') AND
                                                                                                                  os.id_order_state NOT IN ('8')
                                                                                                              )
                                                                                                          ) AND sa.id_product = od.product_id AND
                                                                                                          sa.id_product_attribute = od.product_attribute_id
                                                                                                          GROUP BY od.product_id, od.product_attribute_id
                                                                                                      )
                                                                                                      WHERE sa.id_shop = 1 AND sa.id_product = 3374;
                                                                                                      

                                                                                                      If the sum is null, the subquery has to return 0. I get this query update from prestashop class (StockManager.php, method: updateReservedProductQuantity).

                                                                                                      This is the original code:

                                                                                                      $updateReservedQuantityQuery = '
                                                                                                                  UPDATE {table_prefix}stock_available sa
                                                                                                                  SET sa.reserved_quantity = (
                                                                                                                      SELECT SUM(od.product_quantity - od.product_quantity_refunded)
                                                                                                                      FROM {table_prefix}orders o
                                                                                                                      INNER JOIN {table_prefix}order_detail od ON od.id_order = o.id_order
                                                                                                                      INNER JOIN {table_prefix}order_state os ON os.id_order_state = o.current_state
                                                                                                                      WHERE o.id_shop = :shop_id AND
                                                                                                                      os.shipped != 1 AND (
                                                                                                                          o.valid = 1 OR (
                                                                                                                              os.id_order_state != :error_state AND
                                                                                                                              os.id_order_state != :cancellation_state
                                                                                                                          )
                                                                                                                      ) AND sa.id_product = od.product_id AND
                                                                                                                      sa.id_product_attribute = od.product_attribute_id
                                                                                                                      GROUP BY od.product_id, od.product_attribute_id
                                                                                                                  )
                                                                                                                  WHERE sa.id_shop = :shop_id
                                                                                                              ';
                                                                                                      
                                                                                                              $strParams = array(
                                                                                                                  '{table_prefix}' => _DB_PREFIX_,
                                                                                                                  ':shop_id' => (int) $shopId,
                                                                                                                  ':error_state' => (int) $errorState,
                                                                                                                  ':cancellation_state' => (int) $cancellationState,
                                                                                                              );
                                                                                                      
                                                                                                              if ($idProduct) {
                                                                                                                  $updateReservedQuantityQuery .= ' AND sa.id_product = :product_id';
                                                                                                                  $strParams[':product_id'] = (int) $idProduct;
                                                                                                              }
                                                                                                      
                                                                                                              if ($idOrder) {
                                                                                                                  $updateReservedQuantityQuery .= ' AND sa.id_product IN (SELECT product_id FROM {table_prefix}order_detail WHERE id_order = :order_id)';
                                                                                                                  $strParams[':order_id'] = (int) $idOrder;
                                                                                                              }
                                                                                                      
                                                                                                              $updateReservedQuantityQuery = strtr($updateReservedQuantityQuery, $strParams); 
                                                                                                      

                                                                                                      Why always return null ?

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-14 at 11:03

                                                                                                      You need to put the ifnull check on the outer query, not the inner, which can return no rows.

                                                                                                      You can use coalesce here, such as:

                                                                                                      UPDATE ps_stock_available sa
                                                                                                      SET sa.reserved_quantity = coalesce((
                                                                                                          SELECT SUM(od.product_quantity - od.product_quantity_refunded)
                                                                                                          FROM ps_orders o
                                                                                                          INNER JOIN ps_order_detail od ON od.id_order = o.id_order
                                                                                                          INNER JOIN ps_order_state os ON os.id_order_state = o.current_state
                                                                                                          WHERE o.id_shop = 1 AND
                                                                                                          os.shipped != 1 AND (
                                                                                                              o.valid = 1 OR (
                                                                                                                  os.id_order_state NOT IN ('6,28,59') AND
                                                                                                                  os.id_order_state NOT IN ('8')
                                                                                                              )
                                                                                                          ) AND sa.id_product = od.product_id AND
                                                                                                          sa.id_product_attribute = od.product_attribute_id
                                                                                                          GROUP BY od.product_id, od.product_attribute_id
                                                                                                      ), 0)
                                                                                                      WHERE sa.id_shop = 1 AND sa.id_product = 3374;
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/71466632

                                                                                                      QUESTION

                                                                                                      How can I access Configuration::get('PS_LAST_QTIES') at core.js?
                                                                                                      Asked 2022-Mar-03 at 09:30

                                                                                                      at prestashop 1.7 how could I access Configuration::get('PS_LAST_QTIES') at core.js?

                                                                                                      Thank you, Miguel Gibert

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-03 at 09:30

                                                                                                      I've sorted it out by passing the variable through the ProductController.php

                                                                                                      at $this->ajaxRender(Tools::jsonEncode([

                                                                                                      I added: 'ps_last_qties' => Configuration::get('PS_LAST_QTIES')

                                                                                                      and then I received it at core.js: o.default.on("updatedProduct", function (e) {

                                                                                                      and was able to use it as e.ps_last_qties

                                                                                                      Source https://stackoverflow.com/questions/71265896

                                                                                                      QUESTION

                                                                                                      Prestashop module with Symfony cant find the controller
                                                                                                      Asked 2022-Mar-01 at 10:55

                                                                                                      I am creating a module in Prestashop with Symfony but when I try to access my routes I get this error:

                                                                                                      The controller for URI "/modules/youtuber/list" is not callable: Class "Myyoutubemc\Controller\YoutubeController"

                                                                                                      Below is my controller it's located in: /modules/myyotubemc/src/controllers/youtubeController.php

                                                                                                      render('@Modules/your-module/templates/admin/demo.html.twig');
                                                                                                          }
                                                                                                          public function listAction()
                                                                                                          {
                                                                                                              $em = $this->getDoctrine()->getManager();
                                                                                                              $data = $em->getRepository(YoutubeComment::class)->findAll();
                                                                                                              return $this->render(
                                                                                                                  '@Modules/myyoutubemc/templates/admin/list.html.twig',
                                                                                                                  [
                                                                                                                      'data' => $data
                                                                                                                  ]
                                                                                                              );
                                                                                                          }
                                                                                                      

                                                                                                      below is my routes located at my_module/config/routes.yml

                                                                                                      
                                                                                                      youtube-list:
                                                                                                          path: youtuber/list
                                                                                                          methods: [GET]
                                                                                                          defaults:
                                                                                                            _controller: 'Myyoutubemc\Controller\YoutubeController::listAction'
                                                                                                      

                                                                                                      How can I solve it Please ?.

                                                                                                      Below is the error screenshot

                                                                                                      ANSWER

                                                                                                      Answered 2022-Mar-01 at 10:55

                                                                                                      QUESTION

                                                                                                      Prestashop: Get parent category informations from the sub-category page
                                                                                                      Asked 2022-Feb-28 at 14:46

                                                                                                      I build a site on prestashop with a child theme based on the classic theme. For my needs i've got a page for main categories with an hero section where i display the main category name, the cover image of the category, the sub-categories and a description. (see on the attached image)

                                                                                                      hero section

                                                                                                      Now i need to keep this section like that when i go to the sub-category page. Keep the title, image, sub-categories, etc. Just the content must change.

                                                                                                      For now there is my code to display this hero section, located in the layout-left-column.tpl (to be before all the main content and after the header) :

                                                                                                      {block name="hero_content"}
                                                                                                          {if Tools::getValue('id_category') == 11 || 19 || 20 || 21 || 22 || 23}
                                                                                                              
                                                                                                                  {if $listing.pagination.items_shown_from == 1}
                                                                                                                      
                                                                                                                          {$category.name}
                                                                                                                      
                                                                                                                      
                                                                                                                          {include file='catalog/_partials/subcategories.tpl'}
                                                                                                                      
                                                                                                                      
                                                                                                                          {$category.description nofilter}
                                                                                                                      
                                                                                                                  {/if}
                                                                                                              
                                                                                                          {/if}
                                                                                                      {/block}
                                                                                                      

                                                                                                      But as i expected when i go to a sub-category this section change with the informations of this sub-category.

                                                                                                      How can i keep this section with the parent category informations ?

                                                                                                      Ps: I tried to hit the function Category::getParentsCategories(), but nothing. And i'm working with Prestashop 1.7.8.3

                                                                                                      Thank's for your time.

                                                                                                      ANSWER

                                                                                                      Answered 2022-Feb-28 at 14:42

                                                                                                      [UPDATE] Problem Solved

                                                                                                      I finaly solved my problème with this topic : Prestashop subcategory parent

                                                                                                      And with adaptations :

                                                                                                      In a custom module class where i create a function :

                                                                                                      public function hookDisplayHeaderCategory($params) {
                                                                                                              if (isset($params['current_category']) && !empty($params['current_category'])) {
                                                                                                                  $id_lang = $this->context->language->id;
                                                                                                                  $parent_category = new Category((int) $params['current_category']);
                                                                                                                  $sub_categories = Category::getChildren((int) $params['current_category'], $id_lang);
                                                                                                                  if (Validate::isLoadedObject($parent_category)) {
                                                                                                                      $this->context->smarty->assign(array(
                                                                                                                          "parent_category" => $parent_category,
                                                                                                                          "parent_category_name"   =>  $parent_category->name,
                                                                                                                          "parent_category_description"   => $parent_category->description,
                                                                                                                          "sub_categories"    =>  $sub_categories,
                                                                                                                      ));
                                                                                                                  }
                                                                                                              }
                                                                                                      
                                                                                                              return $this->display(__FILE__, 'category_hero.tpl');
                                                                                                          }
                                                                                                      

                                                                                                      Create a view in this module with the hero section :

                                                                                                      
                                                                                                              
                                                                                                                  {$parent_category_name[1]}
                                                                                                              
                                                                                                              
                                                                                                                  {include file='catalog/_partials/subcategories.tpl' subcategories=$sub_categories}
                                                                                                              
                                                                                                              
                                                                                                                  {$parent_category_description[1] nofilter}
                                                                                                              
                                                                                                      
                                                                                                      

                                                                                                      If it can help somebody in the same case.

                                                                                                      Source https://stackoverflow.com/questions/71255278

                                                                                                      QUESTION

                                                                                                      Days to update Error 400: redirect_uri_mismatch?
                                                                                                      Asked 2022-Feb-21 at 12:48

                                                                                                      I have a prestashop shop that uses social login. And a few days ago when the customer tries to log in this message appears.

                                                                                                      You cannot login to this application because it does not comply with Google's OAuth 2.0 policy.

                                                                                                      If you are the developer of the app, please register the redirect URI in the Google Cloud Console.

                                                                                                      I have edited the redirect address, as I didn't have a secure link, I had the same address, but http instead of https.

                                                                                                      I changed the address a few days ago, but I still get the same message and the old, unsecured address.

                                                                                                      The message when changing the url indicated that it could take minutes or hours, but it has been several days and the address has not been updated.

                                                                                                      Any idea? Thanks!

                                                                                                      ANSWER

                                                                                                      Answered 2022-Feb-21 at 10:59

                                                                                                      While using Google OAuth for OpenID login, you have 2 levels of configuring your redirect URI.

                                                                                                      • Configure the allowed redirect URIs in your OAuth credentials screen in the Google cloud console.
                                                                                                      • Configure the same redirect URI in your application which sends the authorization request. Your authorization request should comprise of the same redirect URI.

                                                                                                      As you mentioned, you might have updated your OAuth credential redirect URIs in console, but your app might be sending authorization response with the old URL itself. So, it will get rejected.

                                                                                                      And yes, make sure the URI is an exact match. AFAIK, even a trailing slash can create problems.

                                                                                                      Source https://stackoverflow.com/questions/71202530

                                                                                                      QUESTION

                                                                                                      How check if new function is working on prestashop
                                                                                                      Asked 2022-Feb-16 at 12:37

                                                                                                      I'm new in prestashop and there is a thing that i don't understand.

                                                                                                      I need to add a function that get a file CSV and stock all in a array. This function will be added in a exixsting Class in this path "/modules/sdevmanomano/classes/MyClass.php" Now i have to test the new function, and it the end of the class (out of the {}), i did a var_dump of my object.method(). When i go at the adress of file in my browser, i get nothing. (i m in the correct path). Why? Exemple:

                                                                                                      /modules/sdevmanomano/classes/MyClass.php
                                                                                                      if (!defined('_PS_VERSION_')) {
                                                                                                          exit;
                                                                                                      }
                                                                                                      
                                                                                                      include_once(dirname(__FILE__) . '/OtherClass.php');
                                                                                                      
                                                                                                      class MyClass
                                                                                                      {
                                                                                                      ...
                                                                                                      //Before execute the code i want check if he has open correctly the CSV in tmpName
                                                                                                          private function getDeliveryPrices(){
                                                                                                              $tmpName = fopen(dirname(dirname(__FILE__)) . '/prices/prezzi_spedizione_francia.csv', 'r');
                                                                                                              if ($tmpName){
                                                                                                                 $csvAsArray = 'ok';
                                                                                                              } else {
                                                                                                                  $csvAsArray = 'errore';
                                                                                                              }
                                                                                                      
                                                                                                              return $csvAsArray;
                                                                                                          }
                                                                                                      }
                                                                                                      // end of class
                                                                                                      $test = new MyClass();
                                                                                                      
                                                                                                      $res = $test->getDeliveryPrice();
                                                                                                      var_dump($res);
                                                                                                      

                                                                                                      Normally at this point, at the adresse https:/.../modules/sdevmanomano/classes/MyClass.php i have to see my dump, but didn' happen. Why ?

                                                                                                      ANSWER

                                                                                                      Answered 2022-Feb-16 at 12:37

                                                                                                      Assuming you would want to use your php script outside a PrestaShop session within the module context, here is how you could require the PrestaShop configuration when on a stand-alone php script:

                                                                                                      // /modules/sdevmanomano/classes/MyClass.php
                                                                                                      
                                                                                                      /*
                                                                                                       * Require the PrestaShop configuration
                                                                                                       * relative to the location of this script
                                                                                                       */
                                                                                                      reqire_once(dirname(__FILE__) . '../../../config/config.inc.php';
                                                                                                      
                                                                                                      // Then you have access to _PS_VERSION_
                                                                                                      if (!defined('_PS_VERSION_')) {
                                                                                                          exit;
                                                                                                      }
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/71128606

                                                                                                      QUESTION

                                                                                                      Access Prestashop cookies from JavaScript
                                                                                                      Asked 2022-Feb-15 at 17:56

                                                                                                      Any method to read Prestashop Cookies from Javascript ?

                                                                                                      Context::getContext()->cookie
                                                                                                      

                                                                                                      I try with

                                                                                                      document.cookie
                                                                                                      

                                                                                                      But can't acces to the prestashop Cookies, any idea please ?

                                                                                                      ANSWER

                                                                                                      Answered 2022-Feb-15 at 17:56

                                                                                                      You can get Cookie content in PHP and set into a template as JS variable.

                                                                                                      You assign with PHP

                                                                                                      $context->smarty->assign('yourData', $dataFromCookie);
                                                                                                      

                                                                                                      and receive in your template file:

                                                                                                      {addJsDef name=yourDataVar}{$yourData}{/addJsDef}
                                                                                                      

                                                                                                      Source https://stackoverflow.com/questions/71124508

                                                                                                      QUESTION

                                                                                                      Why does *ngIf seem to break my reactive form? How do I handle conditional Inputs and validation in Angular?
                                                                                                      Asked 2022-Jan-27 at 18:25

                                                                                                      What I want to accomplish is for the form to change as the user changes the form type from the radio.

                                                                                                      Standard basically has 2 selects (one classic and a fancier one, made with ng-select) and custom has a simple classic text input.

                                                                                                      I am trying to change the form's functionality dynamically as the form type changes using the radio.

                                                                                                      Besides trying to use formBuilder.group, I also tried using .setValidators on the individual inputs, but the result is the same: when I change the radio and the custom_channel_name input is shown i get this console error "Error: Cannot find control with name: 'custom_channel_name'"

                                                                                                      What am I doing wrong and how do I properly handle reactive forms in this fashion?

                                                                                                      What I have so far looks like this: https://i.imgur.com/n24mKs7.png , https://i.imgur.com/FfCgXFX.png

                                                                                                      [ component.html ]

                                                                                                      
                                                                                                        
                                                                                                          
                                                                                                            
                                                                                                            
                                                                                                              Channel
                                                                                                              
                                                                                                                {{ channel }}
                                                                                                              
                                                                                                            
                                                                                                            
                                                                                                              Countries
                                                                                                              
                                                                                                            
                                                                                                          
                                                                                                          
                                                                                                            Custom Channel
                                                                                                              
                                                                                                          
                                                                                                          
                                                                                                            
                                                                                                              Channel Type
                                                                                                              
                                                                                                                
                                                                                                                  
                                                                                                                  Standard
                                                                                                                
                                                                                                                
                                                                                                                  
                                                                                                                  Custom
                                                                                                                
                                                                                                              
                                                                                                            
                                                                                                            
                                                                                                              
                                                                                                                Assign Channel
                                                                                                                
                                                                                                              
                                                                                                            
                                                                                                          
                                                                                                        
                                                                                                      
                                                                                                      

                                                                                                      [ component.ts ]

                                                                                                      export class OrganizationChannelsComponent implements OnInit {
                                                                                                      
                                                                                                        selectChannelsSources: Array = ["eMag Marketplace", "Vtex", "Shopify", "Magento1", "Magento2", "WooCommerce", "Prestashop", "TeamShare", "Gomag", "Opencart", "MerchantPro", "Cscart", "Allegro", "Idosell", "ChannelAdvisor", "Shoprenter", "Transfer", "Defecte/Defects", "Manual Order"];
                                                                                                        selectCountriesSources: Array = [];
                                                                                                        icons = {
                                                                                                          close: faTimes,
                                                                                                          plus: faPlus
                                                                                                        }
                                                                                                      
                                                                                                        organizationChannelForm!: FormGroup;
                                                                                                      
                                                                                                        selectedCountries: Array = [];
                                                                                                        selectedChannel: Channel | undefined;
                                                                                                        isChannelTypeStandard: boolean = true;
                                                                                                      
                                                                                                        @Input() organizationId!: ID;
                                                                                                      
                                                                                                        organizationChannels$: Observable = new BehaviorSubject([]);
                                                                                                        channels$: Observable = new BehaviorSubject([]);
                                                                                                      
                                                                                                        constructor(
                                                                                                          private organizationChannelsService: OrganizationsChannelsService,
                                                                                                          private organizationChannelsQuery: OrganizationChannelsQuery,
                                                                                                          private countriesService: CountriesService,
                                                                                                          private toasterService: ToasterService,
                                                                                                          private formBuilder: FormBuilder,
                                                                                                        ) { }
                                                                                                      
                                                                                                        ngOnInit(): void {
                                                                                                          this.organizationChannelForm = this.formBuilder.group({
                                                                                                            channel_id: ['', Validators.required],
                                                                                                          });
                                                                                                      
                                                                                                          this.organizationChannelsService.getOrganizationChannels(this.organizationId).subscribe();
                                                                                                          this.organizationChannels$ = this.organizationChannelsQuery.selectOrganizationChannels(this.organizationId as number);
                                                                                                          this.countriesService.get().subscribe(countries => this.selectCountriesSources = countries);
                                                                                                        }
                                                                                                      
                                                                                                        updateOrganizationChannelForm() {
                                                                                                          if (this.isChannelTypeStandard) {
                                                                                                            this.organizationChannelForm = this.formBuilder.group({
                                                                                                              channel_id: ['', Validators.required],
                                                                                                            });
                                                                                                          }
                                                                                                          else {
                                                                                                            this.organizationChannelForm = this.formBuilder.group({
                                                                                                              custom_channel_name: [Validators.required, Validators.minLength(8)]
                                                                                                            });
                                                                                                          }    
                                                                                                        }
                                                                                                      }
                                                                                                      

                                                                                                      ANSWER

                                                                                                      Answered 2022-Jan-27 at 18:25

                                                                                                      Documentation to the rescue! here is the official link to creating dynamic forms: https://angular.io/guide/reactive-forms#creating-dynamic-forms

                                                                                                      basically you need formArray instead of formGroup for all the controls that are going to be conditionally visible on UI, read the docs and if it becomes difficult to understand then let me know I'll create a demo.

                                                                                                      Source https://stackoverflow.com/questions/70879569

                                                                                                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                                      Vulnerabilities

                                                                                                      No vulnerabilities reported

                                                                                                      Install PrestaShop

                                                                                                      If you downloaded the source code from GitHub, read our guide on installing PrestaShop for development. If you intend to install a production shop, make sure to download the latest version from our download page, then read the install guide for users.

                                                                                                      Support

                                                                                                      For technical information (core, module and theme development, performance...), head on to PrestaShop DevDocs. If you want to learn how to use PrestaShop 1.7, read our User documentation.
                                                                                                      Find more information at:
                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit

                                                                                                      Share this Page

                                                                                                      share link

                                                                                                      Explore Related Topics

                                                                                                      Consider Popular Ecommerce Libraries

                                                                                                      saleor

                                                                                                      by saleor

                                                                                                      saleor

                                                                                                      by mirumee

                                                                                                      spree

                                                                                                      by spree

                                                                                                      reaction

                                                                                                      by reactioncommerce

                                                                                                      medusa

                                                                                                      by medusajs

                                                                                                      Try Top Libraries by PrestaShop

                                                                                                      prestashop-icon-font

                                                                                                      by PrestaShopCSS

                                                                                                      docker

                                                                                                      by PrestaShopShell

                                                                                                      PrestaShop-modules

                                                                                                      by PrestaShopPHP

                                                                                                      docs

                                                                                                      by PrestaShopScala

                                                                                                      Compare Ecommerce Libraries with Highest Support

                                                                                                      saleor

                                                                                                      by mirumee

                                                                                                      magento2

                                                                                                      by magento

                                                                                                      woocommerce

                                                                                                      by woocommerce

                                                                                                      shopizer

                                                                                                      by shopizer-ecommerce

                                                                                                      spree

                                                                                                      by spree

                                                                                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                                      Find more libraries
                                                                                                      Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                                      Save this library and start creating your kit