16

If left to default settings, what circumstances would have to occur for Magento 1.7 to consider a cart abandoned? Where is the code that makes this determination located?

I know that this is probably set somewhere in the quote, but I can't find it for the life of me.

I've done some Googling, but like so many Magento questions I'm left empty handed. Thanks!

Jon Surrell
  • 8,394
  • 6
  • 44
  • 52
Kale
  • 601
  • 1
  • 8
  • 25

3 Answers3

15

As you probably know the setting is located here:

Admin => system => Configuration => Sales => Checkout => Quote Lifetime (days)

This will add the setting to the database (core_config_data table) with path:

checkout/cart/delete_quote_after

This path is used in the code on:

app/code/core/Mage/Sales/Model/Observer.php line 54

So when someone is adding something to a cart it will be updated. When a customer logs in and his cart is there it will be updated. When a cart is not updated for the last 30 days. It will be removed.

Extra information:

In case you wonder when this code is used, It is used by the cronjob of magento.

check: App/code/core/Mage/Sales/etc/config.xml line 1732

<crontab>
    <jobs>
        <sales_clean_quotes>
            <schedule>
                <cron_expr>0 0 * * *</cron_expr>
            </schedule>
            <run>
                <model>sales/observer::cleanExpiredQuotes</model>
            </run>
        </sales_clean_quotes>

Hope this helps.

khoekman
  • 1,083
  • 7
  • 14
  • 5
    As an oft quoted sick joke, the observer only cleans out completed orders -> `$quotes->addFieldToFilter('is_active', 0);` and as abandoned carts never get `is_active` set from 1 to 0, abandoned guest carts have infinite staying power and after a year, can consume considerable database storage space. – Fiasco Labs Apr 11 '13 at 00:27
  • I read that that the "Quote Lifetime (days)" only applies to (anonymous) nog-logged-in customers. But a cart from a logged-in user *never* expires. Have you come across this difference in behavior? – snh_nl Mar 22 '15 at 12:17
  • @khoekman **"Check code here"** Links must be updated, they do not exist anymore. – divy3993 Jun 22 '16 at 09:29
  • @divy3993 thanks for pointing out. i have removed the links to the old source code. – khoekman Jun 22 '16 at 10:18
0

The question was about when a cart becomes abandoned, not when the quote expires. As Magento doesn't have abandoned cart functionality, it's arbitrary. The various extensions to add it let you set it.

bluescrubbie
  • 520
  • 4
  • 11
  • 3
    Magento does have an abandoned cart "functionality" in the sense that it has carts it considers abandoned, it just doesn't have a mechanism for doing anything with said carts. – Kale May 02 '14 at 16:42
0

In our e-commerce we've overridden the method cleanExpiredQuotes inside app/code/core/Mage/Sales/Model/Observer.php

Our business rule looks like this:

$quotes = Mage::getModel('sales/quote')->getCollection();     
$quotes->addFieldToFilter('created_at', array('to'=>date("Y-m-d", time()-$lifetime)));

$quotes->addFieldToFilter('is_active', 1);
foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) {
    $quotes->addFieldToFilter($field, $condition);
}
$quotes->walk('delete');