Jump to content
thirty bees forum

Quant

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by Quant

  1. 1 hour ago, wakabayashi said:

    @Quant I am sorry, but I don't understand some things, you said. And with many others I disagree.

    I wanted to say that there is no need to make another version of TB (I am a seller (and understand a little in development)).
    Sellers need functionality stability,
    developers also don't need to make frequent updates.
    ---
    Sorting
    It is necessary to add the display of goods to the basic functionality - in stock or not.
    Where? There are a lot of solutions. If the "respected" decides to do it himself, you must remember to look, there are a lot of nuances.
    This is one of the most requested features!
    ---
    You want to display multiple images in FO.
    The "getProductProperties" method generally needs to be divided into separate parts for getting the character, images, formatting, etc.
    It will be more convenient to override.
    In general, such functionality needs to be obtained through "ProductPresenter ()" (it needs to be done for TB as well), well, everyone needs to think about what he should decide.
    It is necessary to display its variants in the listing in the product card - Color: Black: Green: Red, etc.
    ---
    I am against any functionality of getting Goods in FO, which is not included in the core.
    Maybe you need to create Product :: getNewProductList (etc.): ProductIterator
    Do you want to do optimization? At the iteration stage?
    ---
    Mail -> for new versions OrderState :: mail or a stub for those you don't understand. But it's better to make a Notification class.
    Mail -> queue.
    ---
    All salespeople have different needs. I want the engine to be fast!

  2. 20 hours ago, wakabayashi said:

    It's long ago. I have been here. I have a lot of ToDos on my list. I have taken the most relevant out and post it here:

    Sorry for GoogleTranslate.

    -
    Now, there is no need to complicate the functionality of the core and base theme, which is backward compatible with Prestashop 1.6.
    I understand that the point of backward incompatibility is implemented in version 1.3 and above. I could be wrong.
    Watching github and "Datackick" posts all your wishes will be implemented in version 31.0.0 :).

    ---
    The "Mail" class is the best way to do it. Put everything in one method.

    The path of the classes themselves define the functionality - Order :: sendMail, OrderState :: sendMail.
    And sending letters only in the background (queue) - devSprint03!
    Using a webtrigger is crazy, needs some work!
    You can add the "Notificaton" class.
    ---

    All that concerns redefining the output of products in FrontOffice should be done by modules.
    But - we need one more class for displaying products in FO, which modules should also use - maybe "ProductIterator" or "CatalogProduct".
    ---

    The checkout process should be spared from the buyer's registration choice.
    The main thing for the seller is to receive the order and data for communication with the buyer!
    You can extend the "Customer" class, add a phone. Use the "Address" class as a proxy.
    Depending on the type of delivery or secondary to the country, use the mandatory fields of the "Address" model.

        pickup => Address - false
            invoice_address AS shop address from Config
        mycountrylocaldelivery => Address - true
            invoice_address AS moduleCarrier - Carrier api
         etc. :)
    ---

    If you can do a Fast (basic or not) method "Product :: getProducts (array $ withFeature = [])" - that's cool!
    ---

    Better to keep the core functionality of the store simple and straightforward.
    Expand with modules.

    And it's time to think about "CSS" and "JAVASCRIPT" for the base theme to function!
     

    • Confused 1
  3. On 3/31/2021 at 9:29 AM, datakick said:

    Please ask if you have any questions about anything

    Extend class Feature
    Together with "Multiple feature values" you can extend the feature class.
    Add flag to show or not in Front office. So they can be divided into service ones and those that are used only by the filter.
    Because many people write conditions in templates so as not to show some features.

    Minimum of fixes. 

    class FeatureCore extends ObjectModel
    {
        // 'show_on_front' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => false, 'dbDefault' => '1'],
        public $show_on_front = 1;
    
    //add condition (show_on_front = 1)
    Feature::getFeaturesForComparison
    Product::getFeaturesStatic
    Product::getFrontFeaturesStatic

     

    Better yet, add the "prefix" and "suffix" fields. For example, they can contain the name of the style, the type of value, the name of the picture, etc. Each theme developer can decide how to use them. 

    class FeatureCore extends ObjectModel
    {
        // 'prefix' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => false, 'size' => 64, 'dbNullable' => true],
        public $prefix;
        // 'suffix' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => false, 'size' => 64, 'dbNullable' => true],
        public $suffix;

     

    I understand that there is a lot of work, but it would be cool :)

     

    • Like 1
  4. 17 hours ago, Wartin said:

    It works! Thanks!!

    Now I have to figure out how to use the real delay calculated by the module. How do you do it?

    Mine it's not saved in the database, the module makes the webservice call and use a variable 'data' with the returning values.

     

    Which database?

    When viewing or printing PDF, the current one is used (TEXT_FROM_CURRENT_TB_DELIVERY -> delay).

    What you want will require a lot of code editing!

    Option. Save Adresse -> $ other = 'Als mein benutzerdefinierter Text'

    Delay, replace Verzögerung with Adresse -> $ andere.

     

  5. 21 hours ago, Wartin said:

    I changed a little bit my code to:

    
        public function simulateCarriersOutput(Country $defaultCountry = null, $flush = false)
        {
            $carriers = parent::simulateCarriersOutput($defaultCountry, $flush);
            foreach ($carriers as $id => $carrier) {
                    if ($carrier['id_carrier'] == 264000) {
                            $carriers[$id]['delay'] = 'my updated delay';
                            //$carrier['delay'] = "delay_from_webservice";
                    }
            }
            return $carriers;
        }

    If I print the smarty variable $carriers in order-carrier.tpl with:

    
    {$carriers|@debug_print_var}

    I see the list of carriers modified, with my delay.

    BUT, it's not updated in carrier list

    What am I missing?

     

    Thanks again!!

    My solution:

    class Cart extends CartCore
    {
        public function getDeliveryOptionList(Country $defaultCountry = null, $flush = false)
        {
            // array lang (id_lang => text)
            $delay = [
                1 => 'My text delay!',
            ];
            $deliveryOptionList = parent::getDeliveryOptionList($defaultCountry, $flush);
            foreach ($deliveryOptionList as $idAddress => $deliveryOption) {
                foreach ($deliveryOption as $key => $value) {
                    foreach ($value['carrier_list'] as $idCarrier => $data) {
                        // override Carrier
                        if (2 == $idCarrier) {
                            $deliveryOptionList[$idAddress][$key]['carrier_list'][$idCarrier]['instance']->delay = $delay;
                        }
                    }
                }
            }
            return $deliveryOptionList;
        }
    }

     

     

     

    • Thanks 1
  6. Inventory management is enabled in my store and it is not allowed to order with zero stock.

    One page checkout enabled.

    PS_STOCK_MANAGEMENT = 1

    PS_ORDER_OUT_OF_STOCK = 0

    PS_ORDER_PROCESS_TYPE = 1

    TB_VERSION = 1.1.0-1.1.x Bleeding edge

    THEME - Niara

    --------

    The following happens:

    Product A has 10 units remaining.

    Customer1 puts all 10 units in the cart yesterday and stops.

    Today Customer2 comes in and buys Product A in the amount of 4 units.

    After that, today Customer1 continues ordering, enters the Cart and sees that 10 units are available.

    The real balance of Product A is already 6 units.


    Until he saves the account, he does not see a warning about the lack of quantity of Item A.

    Ok, he saved the account and sees a warning:

    An item (Product A) in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.

     

    Ok, but he doesn't understand how much he needs to change the quantity.

    In the Shopping Cart, he clicks the Downgrade button and sees the message:

    There aren't enough products in stock.

     

    He doesn't know what to do.


    It is better to fix this behavior of the Shopping Cart.

     

    P.S.

    For myself, as a temporary solution, I fixed the processChangeProductInCart method in the Cart class.
    If the real balances of the goods are already less, to check ($ qtyToCheck) set the real quantity.
    We decrease the quantity ($ this-> qty) by the difference between the quantity in the basket and the real quantity,
    or if the actual quantity is less than or equal to 0, then we will remove the item from the cart.

    if (Tools::getValue('op', 'up') == 'down') {
        //$qtyToCheck -= $this->qty;
        if ($cartProduct['stock_quantity'] < $cartProduct['cart_quantity']) {
            $this->qty = ($cartProduct['stock_quantity'] > 0)
                ? $cartProduct['cart_quantity'] - $cartProduct['stock_quantity']
                : -1;
            $qtyToCheck = $cartProduct['stock_quantity'];
            $this->ajax_refresh = true;
        } else {
            $qtyToCheck -= $this->qty;
        }
    } else {
        $qtyToCheck += $this->qty;
    }

     

     

     

  7. We get the wrong redirect with

    index.php?controller=AdminFeatures&id_feature=1&viewfeature&token=64b5166a96bdea51c7bb9a746b2dabfd

    on the

    index.php?controller=AdminFeatures&token=64b5166a96bdea51c7bb9a746b2dabfd&submitFilterfeature_value=2#feature_value

    Change the line in the AdminFeaturesController

    if (Tools::getIsset('submitFilter')) {

    on the

    if (Tools::getIsset('submitFilter'.$this->list_id)) {

    It works now.

     

  8. 15 minutes ago, Traumflug said:

    Your "fix" may work for you, and nice to see it does, but is certainly not a general solution. It always picks the first image type defined, which can be any size.

    I agree.
    In my situation, I could not find a better solution than to write such overrides. Will have to live with them.

    Of course, it's better not to delete the small type 😞

  9. In the AdminProducts controller we have a small picture type. If this type is not or is it disabled for products?

    The initFormAttributes and initFormImages functions have a line that probably does not work correctly:

    $type = ImageType::getByNameNType('%', 'products', 'height');
    //won't find anything

    it's better this way

    $type = ImageType::getByNameNType('*', 'products', 'height');
    //will show first

    In initFormInformations (for inserting pictures in the description), the type small is also hardcoded:

    //type (small) as constant
    foreach ($images as $k => $image) {
        $images[$k]['src'] = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id.'-'.$image['id_image'], ImageType::getFormatedName('small'));
    }

    it's better this way

    //better to find from what is
    $imageType = (ImageType::getImagesTypes('products'))[0]['name'] ?? 'Unknow';
    foreach ($images as $k => $image) {
        $images[$k]['src'] = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id.'-'.$image['id_image'], ImageType::getFormatedName($imageType));
    }

     

    In my store (TB with the latest bleeding edge update) I do not use the "small" type. These fixes work for me. Maybe it should be for everyone.

  10. I want to redefine the templates for the default BO theme, for example _PS_BO_DEFAULT_THEME _. '/template / footer.tpl'.
    Then in AdminController :: display () the wrong folder paths are retrieved.

            // Check if header/footer have been overriden
            $dir = $this->context->smarty->getTemplateDir(1);//.'controllers'.DIRECTORY_SEPARATOR.trim($this->override_folder, '\\/').DIRECTORY_SEPARATOR;
            $moduleListDir = $this->context->smarty->getTemplateDir(1).'helpers'.DIRECTORY_SEPARATOR.'modules_list'.DIRECTORY_SEPARATOR;

     

  11. This is probably the wrong context for "this" inside the "each" function. If you return it as it was in Prestashop, then there will be no error:

    function updateInvoice(invoices) {
      // Update select on product edition line
      $('.edit_product_invoice').each(function () {
        var selected = $(this).children('option:selected').val();
    
        $(this).children('option').remove();
        //$.each(invoices, function (i) {
        for(i in invoices) {
          // Create new option
          var option = $('<option>' + invoices[i].name + '</option>').attr('value', invoices[i].id);
          if (invoices[i].id === selected) {
            option.attr('selected', true);
          }
    
          $(this).append(option);
        }
        //});
      });
    
      // Update select on product addition line
      $('#add_product_product_invoice').each(function () {
        var parent = $(this).children('optgroup.existing');
        parent.children('option').remove();
        $.each(invoices, function (i) {
          // Create new option
          var option = $('<option>' + invoices[i].name + '</option>').attr('value', invoices[i].id);
    
          parent.append(option);
        });
        parent.children('option:first').attr('selected', true);
      });
    
      // Update select on product addition line
      $('#payment_invoice').each(function () {
        $(this).children('option').remove();
        //$.each(invoices, function (i) {
        for(i in invoices) {
          // Create new option
          var option = $('<option>' + invoices[i].name + '</option>').attr('value', invoices[i].id);
    
          $(this).append(option);
        }
        //});
      });
    }

     

    Whoever knows Javascript can confirm this?

     

  12. When I add or remove an item to a BO order I get the following Javascript error:

    In Chromium 79.0.3945.79 (Официальная сборка), Built on Ubuntu , running on Ubuntu 18.04 (64 бит)

    or Windows 7 Google Chrome 79.0.3945.130

    jquery-1.11.0.min.js?ts=1564066310:3 Uncaught TypeError: Cannot read property 'createDocumentFragment' of undefined
        at eb (jquery-1.11.0.min.js?ts=1564066310:3)
        at Function.buildFragment (jquery-1.11.0.min.js?ts=1564066310:3)
        at e.fn.init.domManip (jquery-1.11.0.min.js?ts=1564066310:3)
        at e.fn.init.append (jquery-1.11.0.min.js?ts=1564066310:3)
        at Object.<anonymous> (orders.js?ts=1580215242:59)
        at Function.each (jquery-1.11.0.min.js?ts=1564066310:2)
        at HTMLSelectElement.<anonymous> (orders.js?ts=1580215242:52)
        at Function.each (jquery-1.11.0.min.js?ts=1564066310:2)
        at e.fn.init.each (jquery-1.11.0.min.js?ts=1564066310:2)
        at updateInvoice (orders.js?ts=1580215242:48)
    eb @ jquery-1.11.0.min.js?ts=1564066310:3
    buildFragment @ jquery-1.11.0.min.js?ts=1564066310:3
    domManip @ jquery-1.11.0.min.js?ts=1564066310:3
    append @ jquery-1.11.0.min.js?ts=1564066310:3
    (anonymous) @ orders.js?ts=1580215242:59
    each @ jquery-1.11.0.min.js?ts=1564066310:2
    (anonymous) @ orders.js?ts=1580215242:52
    each @ jquery-1.11.0.min.js?ts=1564066310:2
    each @ jquery-1.11.0.min.js?ts=1564066310:2
    updateInvoice @ orders.js?ts=1580215242:48
    success @ orders.js?ts=1580215242:557
    j @ jquery-1.11.0.min.js?ts=1564066310:2
    fireWith @ jquery-1.11.0.min.js?ts=1564066310:2
    x @ jquery-1.11.0.min.js?ts=1564066310:4
    b @ jquery-1.11.0.min.js?ts=1564066310:4
    XMLHttpRequest.send (async)
    send @ jquery-1.11.0.min.js?ts=1564066310:4
    ajax @ jquery-1.11.0.min.js?ts=1564066310:4
    (anonymous) @ orders.js?ts=1580215242:542
    dispatch @ jquery-1.11.0.min.js?ts=1564066310:3
    r.handle @ jquery-1.11.0.min.js?ts=1564066310:3

    In Firefox 72.0.1 (64-bit) on Ubuntu 18.10:

    TypeError: a is undefinedjquery-1.11.0.min.js:3:15071
        jQuery 4
            eb
            buildFragment
            domManip
            append
        updateInvoice http://tb110.local/js/admin/orders.js?ts=1580215242:59
        each jQuery
        updateInvoice http://tb110.local/js/admin/orders.js?ts=1580215242:52
        jQuery 2
            each
            each
        updateInvoice http://tb110.local/js/admin/orders.js?ts=1580215242:48
        success http://tb110.local/js/admin/orders.js?ts=1580215242:557
        jQuery 4
            j
            fireWith
            x
            b

    My shop is Thirtybees 1.1.x Bleeding Edge last release. Files are not modified.

    Someone can check the addition or removal of goods in your order.

  13. We have two ajax functions (ajaxProcessAddProductOnOrder, ajaxProcessEditProductOnOrder) to edit and add goods from BO that use the ./orders/_product_line.tpl template but do not define $product['customized_product_quantity'].
    Accordingly, we have such a message in the error log:

    2020/01/28 13:29:47 [error] 675#675: *124 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: customized_product_quantity in /home/vagrant/public_html/cache/smarty/compile/7c/80/09/7c80093774885aab8180ca74c940683e358afd6d_0.file._product_line.tpl.php on line 133PHP message: PHP Notice:  Undefined index: customized_product_quantity in /home/vagrant/public_html/cache/smarty/compile/7c/80/09/7c80093774885aab8180ca74c940683e358afd6d_0.file._product_line.tpl.php on line 133"

     

  14. On 1/26/2020 at 3:10 PM, Traumflug said:

    Nice catch. That's when attempting to edit a product in an order in back office, bottommost panel, right?

    Yes.

    On 1/26/2020 at 3:10 PM, Traumflug said:

    I'm just curious how you managed to get this error message, I don't get it. Which kind of PHP is this?

    My currently php version:

    PHP 7.3.10-1+0~20191008.45+debian9~1.gbp365209 (cli) (built: Oct  8 2019 05:48:14) ( NTS )

     

    • Like 1
  15. My shop version 1.1.x Bleeding Edge last release
    The error log shows the following

    2020/01/25 14:02:54 [error] 688#688: *1436 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: currency in /home/vagrant/public_html/controllers/admin/AdminOrdersController.php on line 2713PHP message: PHP Notice:  Trying to get property 'decimals' of non-object in /home/vagrant/public_html/controllers/admin/AdminOrdersController.php on line 2713"

     

  16. There is a bug with displaying colors on the categories page when SmartyCache is enabled.
    It is not fixed in TB and PS (1.6.x).
    Here is an example of how to fix it.

        public function addColorsToProductList(&$products)
        {
            if (!is_array($products) || !count($products) || !file_exists(_PS_THEME_DIR_.'product-list-colors.tpl')) {
                return;
            }
    
            $productsNeedCache = [];
            foreach ($products as &$product) {
                if (!$this->isCached(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']))) {
                    $productsNeedCache[] = (int) $product['id_product'];
                } else {
                    $product['color_list'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']));
                }
            }
    
            unset($product);
    
            $colors = false;
            if (count($productsNeedCache)) {
                $colors = Product::getAttributesColorList($productsNeedCache);
            } else {
                return;
            }
    
            Tools::enableCache();
            foreach ($products as &$product) {
                if (isset($colors[$product['id_product']])) {
                    $tpl = $this->context->smarty->createTemplate(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']));
                    $tpl->assign(
                        [
                            'id_product'  => $product['id_product'],
                            'colors_list' => $colors[$product['id_product']],
                            'link'        => $this->context->link,
                            'img_col_dir' => _THEME_COL_DIR_,
                            'col_img_dir' => _PS_COL_IMG_DIR_,
                        ]
                    );
                    $product['color_list'] = $tpl->fetch(_PS_THEME_DIR_.'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']));
                } 
                if (in_array($product['id_product'], $productsNeedCache) && !isset($colors[$product['id_product']])) {
                    $product['color_list'] = '';
                }
            }
            Tools::restoreCacheSettings();
        }

     

    • Like 1
  17. The blocknewproducts module (ver 2.1.3) does not show products on the categories page when I enable Smarty cache.
    It seems to me that in hookRightColumn() the BlockNewProducts::$cache_new_products is not checked there.
    I changed the function a bit, and then everything works:

        public function hookRightColumn()
        {
            if (!$this->isCached('blocknewproducts.tpl', $this->getCacheId())) {
                if (!isset(BlockNewProducts::$cache_new_products))
                    BlockNewProducts::$cache_new_products = $this->getNewProducts();
    
                if (!BlockNewProducts::$cache_new_products) {
                    return false;
                }
    
                $this->smarty->assign([
                    'new_products' => BlockNewProducts::$cache_new_products,
                    'mediumSize'   => Image::getSize(ImageType::getFormatedName('medium')),
                    'homeSize'     => Image::getSize(ImageType::getFormatedName('home')),
                ]);
            }
    
            return $this->display(__FILE__, 'blocknewproducts.tpl', $this->getCacheId());
        }

     

    Also in hookdisplayHomeTab(), the BlockNewProducts::$cache_new_products check should be used in the IF block, and in hookdisplayHomeTabContent(), the check is generally meaningless.

        public function hookdisplayHomeTab()
        {
            if (!$this->isCached('tab.tpl', $this->getCacheId('blocknewproducts-tab'))) {
                BlockNewProducts::$cache_new_products = $this->getNewProducts();
                
                if (!BlockNewProducts::$cache_new_products)
                    return false;
            }
    
            return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('blocknewproducts-tab'));
        }
    
        public function hookdisplayHomeTabContent()
        {
            if (!$this->isCached(
                'blocknewproducts_home.tpl',
                $this->getCacheId('blocknewproducts-home'))
            ) {
                $this->smarty->assign([
                    'new_products' => BlockNewProducts::$cache_new_products,
                    'mediumSize'   => Image::getSize(ImageType::getFormatedName('medium')),
                    'homeSize'     => Image::getSize(ImageType::getFormatedName('home')),
                ]);
            }
    
            return $this->display(
                __FILE__,
                'blocknewproducts_home.tpl',
                $this->getCacheId('blocknewproducts-home')
            );
        }

    Tell me, my corrections are correct?

  18. The productscategory module gives errors if you enable FullPageCache and disable caching for displayFooterProduct.

    [Mon Apr 22 18:26:22.209248 2019] [:error] [pid 25072] [client 127.0.0.1:53663] PHP Notice:  Undefined index: product in /home/shop/www/modules/productscategory/productscategory.php on line 110, referer: http://tb.local/19-laki
    [Mon Apr 22 18:26:22.209278 2019] [:error] [pid 25072] [client 127.0.0.1:53663] PHP Notice:  Trying to get property of non-object in /home/shop/www/modules/productscategory/productscategory.php on line 110, referer: http://tb.local/19-laki
    [Mon Apr 22 18:26:22.209294 2019] [:error] [pid 25072] [client 127.0.0.1:53663] PHP Notice:  Undefined index: product in /home/shop/www/modules/productscategory/productscategory.php on line 111, referer: http://tb.local/19-laki
    [Mon Apr 22 18:26:22.209698 2019] [:error] [pid 25072] [client 127.0.0.1:53663] PHP Notice:  Trying to get property of non-object in /home/shop/www/modules/productscategory/productscategory.php on line 113, referer: http://tb.local/19-laki

    Im use TB ver 1.0.8 (community theme) and php5.6.

    How to fix it?

×
×
  • Create New...