Skip to content
View in the app

A better way to browse. Learn more.

thirty bees forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

customized products bug in cart

Featured Replies

in TB 1.0.3: when you add say 3 text fields for customization in BO product and you add to cart, the sub-total line in cart shows the wrong price. however the total shows the correct amount: 0_1515707933857_2018-01-12 10_58_22-Order - My Store.jpg

  • Author

the problem only happens when you have combinations. can you please test again with a product that has combinations?

I have confirmed your issue. Lets hope they can find a solution for it soon. As a matter of fact I found another error on doing so. When I try to decrease the number of items, I get this... 0_1515787546238_Capture.PNG

Might be something minor just like the Webservice issue that was fixed the other day.

This seems to have fixed it for me, give it a try...

Replace the function in /classes/Cart.php, protected function updateCustomizationQuantity, with the following code.. ``` protected function _updateCustomizationQuantity($quantityChange, $idCustomization, $idProduct, $idProductAttribute, $idAddressDelivery, $operator = 'up') { // Link customization to product combination when it is first added to cart if (empty($idCustomization)) { $customization = $this->getProductCustomization($idProduct, null, true); foreach ($customization as $field) { if ($field['quantity'] == 0) { Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'customization SET quantity = '.(int) $quantityChange.', id_product_attribute = '.(int) $idProductAttribute.', id_address_delivery = '.(int) $idAddressDelivery.', in_cart = 1 WHERE id_customization = '.(int) $field['idcustomization']); } } }

    /* Deletion */
    if (!empty($idCustomization) && (int) $quantityChange < 1) {
        return $this->_deleteCustomization((int) $idCustomization, (int) $idProduct, (int) $idProductAttribute);
    }

    /* Quantity update */
    if (!empty($idCustomization)) {
        $result = Db::getInstance()->getRow('SELECT `quantity` FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.(int) $idCustomization);
        if ($result && Db::getInstance()->NumRows()) {
            if ($operator == 'down' && (int)$result['quantity'] - (int) $quantityChange < 1) {
                return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.(int) $idCustomization);
            }

            return Db::getInstance()->execute('
                UPDATE `'._DB_PREFIX_.'customization`
                SET
                    `quantity` = `quantity` '.($operator == 'up' ? '+ ' : '- ').(int) $quantityChange.',
                    `id_address_delivery` = '.(int) $idAddressDelivery.',
                    `in_cart` = 1
                WHERE `id_customization` = '.(int) $idCustomization);
        } else {
            Db::getInstance()->execute('
                UPDATE `'._DB_PREFIX_.'customization`
                SET `id_address_delivery` = '.(int) $idAddressDelivery.',
                `in_cart` = 1
                WHERE `id_customization` = '.(int) $idCustomization);
        }
    }
    // refresh cache of static::_products
    $this->_products = $this->getProducts(true);
    $this->update();

    return true;
}

``` if this works for everyone, I'll make a pull request for it..

It seems like it works for me, I dont understand I guess what you're saying. I can add, and delete items in the cart with no issue. If this fix isn't the correct solution, at least we know the function causing the issue, and you can fix it. I made a video about it, but cant seem to share it here anymore. ;( Maybe this will work.. https://vimeo.com/250966125

@mdekker I've commented on few lines in github on Cart.php. Check them when you have time, because I believe they might help.

How about this one, it only changes two lines from the original 1.0.x file ``` protected function updateCustomizationQuantity($quantityChange, $idCustomization, $idProduct, $idProductAttribute, $idAddressDelivery, $operator = 'up') { // Link customization to product combination when it is first added to cart if (empty($idCustomization) && $operator === 'up') { $customization = $this->getProductCustomization($idProduct, null, true); foreach ($customization as $field) { if ((int) $field['quantity'] === 0) { Db::getInstance()->update( 'customization', [ 'quantity' => (int) $quantityChange, 'idproduct' => (int) $idProduct, 'idproductattribute' => (int) $idProductAttribute, 'idaddressdelivery' => (int) $idAddressDelivery, 'incart' => true, ], 'id_customization = '.(int) $field['idcustomization'] ); } } }

    /* Quantity update */
    if (!empty($idCustomization)) {
        $result = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
            (new DbQuery())
                ->select('`quantity`')
                ->from('customization')
                ->where('`id_customization` = '.(int) $idCustomization)
        );

        if ($operator === 'down' && ((int) $result - (int) $quantityChange) < 1) {
            return Db::getInstance()->delete('customization', '`id_customization` = '.(int) $idCustomization);
        }

        return Db::getInstance()->update(
            'customization',
            [
                'quantity'            => ['type' => 'sql', 'value' => '`quantity` '.($operator === 'up' ? '+' : '-').(int) $quantityChange],
                'id_address_delivery' => (int) $idAddressDelivery,
                'in_cart'             => true,
            ],
            '`id_customization` = '.(int) $idCustomization
        );
    }
    // refresh cache of static::_products
    $this->_products = $this->getProducts(true);
    $this->update();

    return true;
}

```

  • Author

yes, for me this fixes the problem with wrong sub totals in cart and also when you delete the customized product from the cart, it removes the product completely (as intended I guess...)

  • 2 years later...

Hello. I know this is an old thread, but some customer told me she couldn't pay for two personalized items (items with customizations, in fact just a text field)

She had to pay just one. This is what I see in the BO:

image.png.d8908893ed13cad6c990fcdf1a1a072f.png

 

I saw your code, @SLiCK_303, it seems like it's what I have in that function. I'm using 1.1.x.

There are other issues with custom products, I'm trying to figure it out in other thread (and has an issue in Github).

Do you have had the same problem again?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.