Jump to content
thirty bees forum

Wartin

Members
  • Posts

    347
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Wartin

  1. Hello. A month ago I saw a store that showed thumbnails of the products listed as you type. I tried to do it, and found this:

    https://www.prestashop.com/forums/topic/511807-add-images-in-search-bar/

    After changing some variable and fields names I managed to make it work, but changing /classes/Search.php. Now I know how to make overrides, here is the explanation for Niara theme. Again if there are changes to make it work better just tell me.

    First we change one query and then the js code to show the products with the image.

    1) copy classes/Search.php to override/classes/

    2) edit override/classes/Search.php, change this line:

    class SearchCore

    to

    class Search extends SearchCore

    3) go to this
     

            if ($ajax) {
    
                ...
    
             }

    and change the whole block to:

            if ($ajax) {
                $sql = 'SELECT DISTINCT p.id_product, pl.name pname, cl.name cname,
                                                    cl.link_rewrite crewrite, pl.link_rewrite prewrite '.$score.', pi.id_image pimg
                                            FROM '._DB_PREFIX_.'product p
                                            INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
                                                    p.`id_product` = pl.`id_product`
                                                    AND pl.`id_lang` = '.(int) $idLang.Shop::addSqlRestrictionOnLang('pl').'
                                            )
                                            '.Shop::addSqlAssociation('product', 'p').'
                                            INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (
                                                    product_shop.`id_category_default` = cl.`id_category`
                                                    AND cl.`id_lang` = '.(int) $idLang.Shop::addSqlRestrictionOnLang('cl').'
                                            )
                                                INNER JOIN `'._DB_PREFIX_.'image` pi ON (
                                                    p.`id_product` = pi.`id_product`
                                                    AND position = 1
                                                )
                                            WHERE p.`id_product` '.$productPool.'
                                            ORDER BY position DESC LIMIT 10';
    
                return $db->executeS($sql, true, false);
            }
    
    

    Delete every function but the one we changed. At the bottom don't forget to leave a '}' to close the class definition.

    In order to make TB take the override, delete /cache/class_index.php

    We've made the query that now contains our product's image. Now we have to show it.

    Edit /themes/niara/js/modules/blocksearch/blocksearch.js

    And change this:

            parse: function(data) {
              return data.map(function(product) {
                return {
                  data: product,
                  value: product.cname + ' > ' + product.pname
                };
              });
            },

    with:

            parse: function(data) {
              return data.map(function(product) {
                return {
                  data: product,
                  value: '<img src="https://YOUR-STORE/img/p/4/2/' + product.pimg  + '-Niara_small.jpg" /> ' + product.cname + ' > ' + product.pname
                };
              });
            },

     

    Now just type something it the search bar, wait a second and look all the products appear with its images :)

    Search.php

    • Like 1
  2. Well, I could solve the second question, about using one specific carrier for one (or more) cities (in fact postal codes).

    I followed this post: https://www.prestashop.com/forums/topic/160695-solved-carrier-by-postcode-the-easy-way/

    but didn't work, so I'll write my steps. It's my first override, if there is something wrong just tell me, please.


    1) Go to Localization -> Zone. Add a new one. In my case I used the name of my city. It could be anything. Remember the Zone ID of this zone, we'll need it.

    2) Go to Transport -> Carriers. Create a new carrier, and select just the zone we've just created. Put some price and weight ranges. Select 'most expensive' in out-of-range (It doesn't work if you don't, I don't know why)

    3) Copy "classes/Address.php" to "override/classes/Address.php".

    4) In line 37 change:  class AddressCore extends ObjectModel
    to:
        class Address extends AddressCore

    Add a } in line 353 (at the very end of the function getZoneById()

    delete lines 39-309

    Line 322, function getZoneById($idAddress), we'll add some lines at start. 2450 is the Postal Code of the city you want to use with a specific Carrier (change it with yours). As it's an array, it could be more than one postal code (just separate them with commas). where it says '9', write your new Zone ID

        public static function getZoneById($idAddress)
        {
            $postcode=self::getPostcodeByAddress($idAddress);

            if(in_array($postcode,array(2450))){
                return 9;
            }
            else{


    Now go just before the function getZoneByAddress, and add this function:

    /**
    * Return postcode of address
    *
    * @param $id_address Address id
    * @return integer postcode
    */

    public static function getPostcodeByAddress($id_address){

            $row = Db::getInstance()->getRow('
            SELECT `postcode`
            FROM '._DB_PREFIX_.'address a
            WHERE a.`id_address` = '.(int)($id_address));

            return $row['postcode'];
    }


    Ready. As we have changed some code, we need to make TB read the changes. Delete /cache/class_index.php

    Go and try to checkout, it should show the carrier you made specially for our new zone.

     

    Address.php

    • Like 1
  3. Hello. I'm trying to set carriers in TB 1.1.x. I can't find a module for TB nor PS that manages shipment costs in Argentina.

    I did find an SDK (Andreani's) that can make queries to ask for the price, based on postal code. Also, I found a module for Magento and an old version of MercadoPago's module that had shipping management (but doesn't work anymore, and had payment too).

    Two questions:

    1) is there a shipping module structure that I can use to adapt the queries and create a module for using this API? I managed to print in product's page the shipping price that is given to me in JSON format (using Andreani's API), but that's not enough.

    2) is it posible to set carriers based on just one City? locally we want to send the packages without using mail, as there are cheap services we prefer. I read about how to make it by countries (making a new zone and moving the country and it's states in)

     

    Any help will be really appreciated.

    Thank you in advance.

  4. Lo que no consigo es calcular el costo de envío. Al parecer las últimas versiones del módulo no trae este cálculo, solo permite cobrar. En github encontré algunos repositorios que en teoría lo hacen, pero usan una versión muy vieja.

    Para envío en Argentina vi que Andreani tiene un SDK y un módulo para Magenta, nada para PS o TB.

    Si alguno/a encuentra la forma sería bueno compartirlo.

    Saludos!

  5. Las zonas tienen dentro países y algunos países tienen provincias. Todo eso está en el menú que andás utilizando

    Ahora bien, qué transportistas tenés creados en Transporte-> transportistas? Qué zonas tienen activadas?

    La verdad es que nunca había agregado los transportistas en los productos como veo que estás haciendo. Sino que al finalizar la orden (desde el frontoffice) te pregunta qué transportistas de los que pueden enviar en la zona donde está el país donde vive el comprador.

     

  6. Lo tengo!

    Volvé a poner el id="colorlabel" como hicimos antes en el template.

    En el JS la función queda:

    $(document).on('click', '.color_pick', function(e) {
      e.preventDefault();
      colorPickerClick($(this));
      findCombination();
      getProductAttribute();
      document.getElementById('colorlabel').innerHTML = $(this).attr('title');
    });

     

    Ahi agarramos el 'title' de donde hacemos el clic, así no hay q esperar que cambie el URI.

    Contame qué tal :)

    • Like 1
  7. Hola. Cuando no escribo una dirección en el campo de crear una cuenta o escribo una incorrecta aparecen los mensajes de validación "Please fill out..." o "Please enter an email address".

    Buscando en internet encontré que se pueden traducir los mensajes al español, y finalmente encontré este archivo en TB:

    js/jquery/plugins/validate/localization/messages_es.js

    donde aparecen todas las cadenas traducidas, y en ese directorio todos los idiomas, pero por algún motivo no están siendo utilizadas.

    ¿Les pasa lo mismo? ¿Saben cómo arreglarlo?

    Gracias de antemano.

  8. Exacto, eso es lo que agregué en la segunda Post Data. Toma el color de la dirección del producto. por eso anda cuando hacés clic dos veces, porque lo toma de ahi. Fijate que en tu Tema no tenés que poner "Color:", sino solo

      document.getElementById('colorlabel').innerHTML = decodeURIComponent(tabValues[0][2]);

     

    Entonces vas a tener que seguir buscando, quién es la función que actualiza el URL del producto. Esa función es la que tiene q ejecutar esa línea de acá arriba.

     

  9. 3 hours ago, toplakd said:

    Will quote myself:

    Reading helps. If not working on first try, then I suggest to read the quote again. So many times until it works 😀

     

    Ha! I swear I read it dozens of times!

    Thank you :)

    • Like 1
  10. Je, tuvimos suerte, me salió.

     

    En el products.js andá a la función que estábamos editando y:

    $(document).on('click', '.color_pick', function(e) {
      e.preventDefault();
      colorPickerClick($(this));
      findCombination();
      getProductAttribute();
      document.getElementById('colorlabel').innerHTML = 'Color: ' + decodeURIComponent(tabValues[0][2]);
    });

     

    Y en el .tpl de tu tema agregá el id="colorlabel" donde querés escribir.

     

    No era tan simple, el decodeURI lee la dirección, que si te fijás cuando cambia de color aparece otra. En mi caso agrega: #/30-color-azul cuando apreto azul.

     

    lo descubrí mirando un poco más abajo, en la función checkUrl()

    Saludos

     

    PD: tené en cuenta que estamos agregando a los atributos ese ID. Si tuvieses más de un atributo (talle, por ejemplo) tal vez no deberíamos usar el ID ahi mismo, sino buscar quién está sobre el "color_to_pick_list".

    PD2: probé cambiar los archivos en mi tienda y funciona al segundo clic. Supongo que tendrás que seguir buscando cuándo escribir bien el label. Pero lo bueno es que ya tenés el string del color.

  11. On 5/26/2020 at 8:57 PM, toplakd said:

    This is not correct solution for the problem, but removing the one at least don't empty other fields once saving.

    For correct solution someone like @datakick or @Traumflug should take a look to see what can be done.

    Hi @toplakd. I'm trying your partial solution, but I don't get what should I delete/comment, as @gatasi asked. Which line of the three?

    I'm tired of re translating strings every time I have to change something. It should be taken into account, It's always necessary to change some strings in order to adapt the platform. After working like two months I have 264 untranslated strings in spanish, I re entered by hand from a new TB instalations but... they keep cleaning when I change something.

    It just erased like 30 strings, after changing one string... It's annoying and time consuming.

    Thanks!

  12. Es que necesitás hacer un par de cosas. Primero agregar en la función esa algo que modifique la línea del Label.

    Acá hice una prueba, en el template del productos (themes/niara/products.tpl) agregué un ID para la etiqueta, para que muestre:

    <label id="tin" class="attribute_label">color!</label>

    Y después la parte de JS, en el archivo themes/niara/js/product.js  línea 355, puse esto

     

    $(document).on('click', '.color_pick', function(e) {
      e.preventDefault();
      colorPickerClick($(this));
      findCombination();
      getProductAttribute();
      document.getElementById('tin').innerHTML = 'color!';
    });

     

    La última línea hace q al apretar el color cambie la etiqueta. Te falta nomás que, en vez de "color!" escriba el color que apretaste, que creo q es el dato que tenías en el comienzo.

    Saludos

  13. On 6/7/2020 at 12:24 PM, Traumflug said:

    Possible? Yes, of course. Editing the template is likely not sufficient, though. One also needs to move PHP and JS code to the other template and find a place to store this phone number without an address.

    I see... I didn't think about where to store it... those are likely too much changes.

    I have read 3-step thread, but I didn't try it yet. I should do it before launching the site... thanks.

    About asking for the telephone, in my case I will ask it later in the checkout (or address creation), so it will be mandatory anyway. I read somewhere that it's better to make clients create accounts and forbid guest accounts, I'm not sure, though.

     

  14. Hola! No traigo la respuesta, pero tal vez ayude.

    Al apretar un botón de color ejecuta una función en javascript (en niara/js/product.js), usando el depurador de firefox (f12, pero con control-shift-c podés marcar un color y ves qué se ejecutaría de apretarse, donde dice 'event') veo esto:

    function(e) {
      e.preventDefault();
      colorPickerClick($(this));
      findCombination();
      getProductAttribute();
    }

    Si querés escribir el color vas a tener que buscar qué botón se apreta y reescribir el

    <label class="attribute_label">Color&nbsp;</label>

    para que diga el color al lado.

    Ojalá sirva. Saludos!

  15. Hello, I'm using 'Just account creation' (I'm not sure if it's like that in english) to let the users create an account with minimal data asking.

    I'd like to ask for telephone there, and not later in address creation.

    I tried to add it in authentication-create.tpl template, but obviously it's not saved nor javascript checked.

    Is it posible?

    Thanks!

  16. 2 hours ago, d3s1gn3r said:

    The problem is that it works only if you visit checkout page. I noticed that this happens because the (+, -) quantity buttons need to call some events that are included in the file: /themes/community-theme-default/js/cart-summary.js, but  the file cart-summary.js is called only when you visit the checkout page. How can i make this work as i need it on my custom theme?

    Hello. Maybe you can add those events in Preferences -> Custom Code -> JS? as the code needs to be loaded in every page, it could work...

     

  17. Hello. I'm trying to change the text that appears in buttons to browse for files, for example in Customization files and in Contact form.

    It says 'Browse...' and 'no file selected'. In translations I see those strings, and they are translated.

    I centered the button using CSS, because it didn't fit the square before that. I'm using Niara.

     

    Thanks!

    Captura de pantalla -2020-05-31 19-36-22.png

  18. Hello. I'm using Niara Theme, TB version 1.1.x.

    When I place an order I receive the email, but in the details there is nothing. Looking inside order_conf.html and .txt it says it's supposed to show {products} and {products_txt}.

    But this is email's source, txt part:

    CANTIDAD
    PRECIO TOTAL
    =20
    =
    =20
    PRODUCTOS=20

    In html's part of the source:

    =09=09=09=09<tr>
    =09=09=09=09=09<td colspan=3D"5" sty=
    le=3D"border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">=
    
    =09=09=09=09=09=09&nbsp;&nbsp;=20
    =09=09=09=09=09</td>
    =09=09=09=09</t=
    r>
    =09=09=09=09<tr>
    =09=09=09=09=09<td colspan=3D"5" style=3D"border:1p=
    x solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
    =09=09=09=09=
    =09=09&nbsp;&nbsp;
    =09=09=09=09=09</td>
    =09=09=09=09</tr>

     

    Any Ideas?

    Thank you in advance.

    Captura de pantalla -2020-05-26 11-38-09.png

×
×
  • Create New...