3

When looking at sales_flat_quote (M1) or quote (M2) table, there are many quotes stuck at is_active=1. Even though there is a sale in sales_flat_order / sales_order.

This does not seem to have a relation to the state of the order (finding complete/processing/canceled orders), nor payment method (finding paypal, checkmo and 3rd party gateway orders).

When joining the quote and sales tables to find orders with 'open' quotes, I find many results on several shops that we manage.

I'm using this query on M1:

SELECT `sales_flat_order`.`state`, `sales_flat_order`.`increment_id`, `sales_flat_order`.`entity_id`, `sales_flat_order`.`created_at`, `sales_flat_order`.`quote_id`, `sales_flat_quote`.`is_active`, `sales_flat_quote`.`customer_email`, `sales_flat_order_payment`.`method` FROM `sales_flat_order` LEFT JOIN sales_flat_quote ON `sales_flat_order`.`quote_id`=`sales_flat_quote`.`entity_id` LEFT JOIN `sales_flat_order_payment` ON sales_flat_order.`entity_id`=sales_flat_order_payment.`parent_id` WHERE `sales_flat_quote`.`is_active` = 1;

and this one on M2:

SELECT `sales_order`.`state`, `sales_order`.`increment_id`, `sales_order`.`entity_id`, `sales_order`.`created_at`, `sales_order`.`quote_id`, `quote`.`is_active`, `quote`.`customer_email`, `sales_order_payment`.`method` FROM `sales_order` LEFT JOIN quote ON `sales_order`.`quote_id`=`quote`.`entity_id` LEFT JOIN `sales_order_payment` ON sales_order.`entity_id`=sales_order_payment.`parent_id` WHERE `quote`.`is_active` = 1;

Am I looking at this the wrong way? Can people confirm the same thing for their M1/M2 shop?

  • guys, have you got any solution? i have also seen some succes order which quote have is_active value 1 . – Camit1dk Jun 27 at 7:25
1

I can confirm that there are a large number of returned rows on several stores that I have access to for your Magento 1 query above. These don't seem to be related with a specific payment method.

There are a number of reaons why the is_active flag is set to 0 or 1.

  • is_active always starts as 1 for cart/quote created by frontend
  • is_active is 0 for quotes created from admin
  • To load quote by Customer Id, is_active = 1 is taken into account
  • When quote is converted to order, is_active becomes 0
  • When you create a quote via API, is_active is always 0

There are a number of reasons in the Magento flow why the is_active flag may remain at 1.

Mage/Sales/Model/Service/Quote.php has a $_shouldInactivateQuote flag which is checked against when the _inactivateQuote() method is called during submitOrder().

This wouldn't allow the flag to be set to 0 if:

  • Nominal items are included in the basket (What are `Recurrent products` and `nominal products`?) - function submitAll()
  • If an exception is thrown when Nominal items are submitted
  • If payment fails (this could be an issue with the payment gateway whereby the order is submitted, but payment fails or it is handled by another process?)

Additionally, there are a number of times in the codebase when the flag is specifically set to true (1).

  • Within Mage/Persistent/Model/Observer.php - setQuoteGuest - would be worth checking if these orders were completed as a guest by adding customer_id to your query above.
  • If checkout fails - see Mage/PayPal/Helper/Checkout.php & Mage/Authorizenet/controllers/Directpost/PaymentController.php
  • Hi Douglas, thanks for the elaborate write-up. When I add customer_id to the query I'm finding entries with and without id. Also there are a lot of orders either cancelled or complete, so those are with a successful payment.. Still not really getting grip on this :( – willem wigman Aug 7 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.