Figuring out Splitting Drupal eCommerce at checkouts

  • October 12th 2012

Drupal eCommerce is gaining momentum. Believe it or not, the day isn’t far when Drupal too would enter into the preferred list of making a Web store. Well, actually its journey into eCommerce has already begun.

And if you’ve had an opportunity of creating an eCommerce store with Drupal, here’s a way to create a checkout path that (relying on the elements of a user’s cart) will segregate the present cart in 2 parts, letting the user to checkout from every one of them separately.

Step1

Drupal gives you a checkout module and a cart that helps the user to include products on a shopping cart followed by putting them on the checkout while exiting the store. There is a Commerce_cart module, which is created for a one-on-one User: Cart proportion. Now this makes it feasible for the users to keep more carts than one.

Another important factor is that cart orders are typically regular orders. They have one order status that is identified with the help of the Commerce_cart module. It signifies that the order is inside the shopping Cart.

Every checkout webpage offers a status of the order, known as the ‘Cart Status’. For instance the ‘Checkout’ as well as ‘Review’ checkout pages stands for Checkout_Checkout and Checkout_Review. These are identified by Commerce_cart as shopping cart orders.

Step 2

While making a selection what order is to be used as the present cart, Commerce_cart tries to find the foremost order, whose cart status is Greatest order_id. So, that’s what is brought back by Commerce_cart_order_load ().

So, in view of providing the needed workability, one has to first offer a fresh checkout pane and the checkout page by employing Hook_commerce_checkout_pane_info() along with Hook_commerce_checkout_page_info()

Step 3

Then, you need to put the pane on the page and make that page the foremost one in the commerce checkout flow. You can also devise a rule, by making use of the Rules module that would tell you what kind of products are there on the cart. Then as per the business logic you’d have, you could make a decision if you want to display or conceal the pane and hence the page also. You can custom code the rules, by employing some action handlers and condition only for once.

It’s the checkout pane that has a convenient form which lets the user choose the part of the order they want to checkout initially. At the summit handler of the pane, products that are there for the first checkout order are moved out from the present order and are included in a fresh order which is made through Comerce_cart_order_new()

It is then that every order is saved by having a cart status by utilizing Commerce_order_status_update(). It is done to ensure that certain custom concession recomputing regulations would fire for every order.

Step 4

At the end, you could set the status of the fresh order to the previous status of the present order (so it shows the existing checkout page), then allot the fresh order item to $ form_state[order]. It’s done so as the form would be effectively redirected to the appropriate next checkout for a fresh order. When customers finish the order1, they are propelled for an extra checkout on the complete page of the workflow of the checkout, to start the checkout procedure once more by their left over cart.

Conclusion

Once all this is done, you would find yourself quite satisfied with the existing code as well as the workflow. You can even find out ways in which you could generalize it and make a contribution to the drupal community.

Our Location

INDIA G-273, Sector-63, Noida, Uttar Pradesh 201301
Email: hr@creativeweblogix.com
Rated 4.8 out of 5.0 for over 16,472 projects by 10,648 clients.
© Copyright 2024 C W Logix Pvt. Ltd®. All Rights Reserved.