Magento Certification: Checkout. Shopping Cart.

Magento Certification: Checkout. Shopping Cart.

Magento Certification is an important issue for any developer connected with Magento. It is not merely a sign of high-level proficiency, but also a mark of profound knowledge and devotion to this sphere. This article opens Magento certification tips and tricks series aimed to prepare its readers for passing the exam.

Amasty team members who passed Magento Certification

Amasty team already has 2 specialists who have passed Magento Certification and another 3 are on the way. We are glad to share our knowledge and help other Magento developers to find easy explanations and answers to the exam questions.

Magento Certification is divided into 10 chapters. And if you start searching information on it in the Internet, you will generally find articles about the first chapters. So we decided to take another way and to start right from Chapter 8 where Checkout process is outlined. Making it even better this topic comprises about 16% of the exam. So even if your study thirst will not suffice for the full course with this article you will have at least some basis for the exam.

How does Magento store information about the shopping cart?

We have sales_flat_quote table, where general information such as customer_id, subtotal, coupon_code, items_qty, creation and update date is stored. In case a client didn’t finish the purchase, this information is displayed in the standard report “Abandoned Carts”.

Products are stored in a separate table sales_flat_quote_item, where one can find information about the product bought, its amount, price and discount applied. Complex types of products (configurable, bundle) occupy a few rows. This is a very important moment, so let’s pay special attention to it.

How are different product types processed when added to the cart?

How are different product types processed when added to the cart?

When we add to the cart one configurable product, let’s say an L-sized T-shirt, we in fact add 2 products: a configurable one (a T-shirt), that stores product price and its general description and a simple product (L size), which is important for accurate calculation of the items left in stock, since even if we have 5 T-shirts left in stock, only one of them might be of L size.

This way we have 2 records in the cart: parent (configurable product) and child (simple product). The reference of the simple product to the configurable one is specified in the field parent_item_id.

2 records in the cart for configurable product

For the bundle product (e.g. computer) that consists of 3 components there will be 4 records: one parent (general product) and 3 for each product out of bundle.

But for the grouped product (e.g. furniture set) that consists of 3 components there will be only 3 records, since there is no parent product in the cart and information about the fact that this is a group product is stored in sales_flat_quote_item_option.

What for do Magento shop owners and developers need these data?

This would help them first and foremost to create accurate discount conditions (shopping cart rules) and secondly to define accurately shipping cost in the cases when it depends on the amount of goods. In theory the way data are stored is not important for user, but up to the latest Magento version there are cases, where this information is significant.

Example

For example we want to provide a discount for the order in case it contains L-sized T-shirts. We go to Admin -> Promotions -> Shopping cart rules -> New rule.  Then we go to tab Actions and choose L-sized T-shirt.

Example 1

Test it. It doesn’t work. What’s the problem? The thing is that L size is a simple product, so it is “not displayed”.

Let’s try another way. We go to tab Conditions and create a condition “If there is at least one L-sized T-shirt…” and (wow!) it works!

Example 2

But what’s the trick? This condition checks all items in the cart ignoring parent-child relations.

We don’t want to call it “bugs”, we prefer to think of them as “features”.

Homework

  1. Learn how custom options of products are stored. A hint: pay attention to table sales_flat_quote_item_option.
  2. Case study: We have a simple product with a custom option. This product is included in a configurable one that also has a custom option. How many items will there be in the quote items table? Please write your variants in the comments.

Don’t forget to check the Abandoned Cart Email extension from Amasty!

Alexander Stelmakh

Alexander Stelmakh

Alex was at the origin of Amasty and takes very active part in the company’s development. Most Amasty products were either created by him or with his assistance. Alex is a Certified Magento Developer and Zend Certified Engineer. Favorite hobby – intellectual games.

You may also like...

4 Responses

  1. Peter Dryke says:

    thanks for share!

  2. Raul E Watson says:

    Hi Alexander,

    I would like to begin saying BIG THANKS for taking the time to share your knowledge for this part of the certification.

    Regarding your question, I think it is not possible to include a simple with a “custom option” as child of the configurable product.

    By default the system does not let you associate it.

    If you force it or try to cheat, let say.. by creating the association, checking it works and then adding the custom option to the simple, the configurable automatically disappears from the front-end and if you try to access it by direct url you will find that none of the options are visible as well as is not possible to add it to the cart.

Leave a Reply

Your email address will not be published. Required fields are marked *