Developer forum

Forum » Ecommerce - Standard features » Use previous order as template for new

Use previous order as template for new

Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Hi.

One of our customers wishes to use previous orders, and simply "order again" the same in a new order.

I know that "Recurring Orders" exist, but thats a slightly different use-case.

Does DynWeb support "re-ordering" out of the box?

Cheers

//Steve


Replies

 
Andrew Rushworth
Reply
This post has been marked as an answer

Hi Stephen,

There is a Re-Order button on the Customers Orders screen:

Just be careful though as it copies all the Custom Fields too. What I did was created a subscriber to clear out all the custom fields on a re-order.

Votes for this answer: 1
 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Stephen,

 

In Swift, as of v1.19 (https://github.com/dynamicweb/Swift/releases/tag/v1.19.0) the Reorder uses the Express Buy to validate orderlines prior to adding them to the cart (not copying the custom fields nor address fields like Andrew mentions.

 

It will check for out of stock/unavailable products, discontinued products and replacement products as well, so you have much more control.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Lots of input.

The short answer is yes.

If you use the customer center (the new one for viewmodels), you can use a customer center command to start the reorder:

https://doc.dynamicweb.com/template-tags/introduction/ecommerce/customer-center-commands

<a class="btn btn-info" href="?CustomerCenterCmd=Reorder&OrderId=@Model.Id">Add order to cart</a>

It will add all the products to cart, and then you can redirect the user to checkout.

Or if you use Swift as Nuno is referring to, you can use express buy. See https://doc.dynamicweb.com/swift/setup-project/other/customer-center#sideNavTitle1-4-2

The reason to get a new cart is that prices can have changed, products discontinued or out of stock, credit limits expired etc. So a validation of the new order usually needs to take place. But you can make a very simplified convert cart to order flow that skips most of the logic in the checkout.

BR Nicolai

Votes for this answer: 1
 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Where do you see that? I am using swift 1.21 with no custom templates

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Ah nvm. I found it now. Cheers!

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Stephen

You can click the cart icon in my orders overview:

Votes for this answer: 1
 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Hei Nicolai.

We first used the express buy option (out of the box), but then realized that - as you said - it does not take into account price changes or discounts which may have expired / been added.

We used the CustomerCenter Reorder CMS and redirect to handlekurv. All the products get added, but unfortunately all with 0 kr.  The customer center does not see the prices. The thing is, we have a custom price provider which puts the price matrix into a session object for the logged in customer id.   I am wondering if the customer center reorder cmd will have difficulty with this?

Cheers

//Steve

EDIT: Its not a priceprovider we use, its a LineAddedNotification. We capture when added to cart, and apply the discounts for that customer to the line.

EDIT 2. When I think about it though. Isnt the LineAddedNotification emitted with express buy when clicking "Add all to basket" ?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Stephen

You have to use a price provider for custom prices or you will run into issues.LineAddedNotification will only fire when products are added one at a time.

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Damn. Ok

I had a look around for some concrete code examples of how to solve this with a custom price provider, but could find none.

Could someone point me in the correct direction?

Our design is currently based on an ExtranetLoginNotification which fires and grabs a customernumber for a group of users 

This customer number is then used in an SQL query against 3 custom tables that are synced from the ERP (they together form the price matrix)

We were advised not to try adding all these customer / discount combinations into DW using the standard discount setup as this would cause way too many price checks, so thats why we imported the tables and used a query to get the customer specific discounts

From that query, we get a bunch of ProductID's and Discount percentages which we assign to a session object, and then use that session object with a LineAddedNotification Subscriber  Its these productids / discounts / descriptions,  that we want to use in the price provider, I would guess, but we do not know how to use the price providers

Hope someone can help.

Cheers

//Steve

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Stephen,

I recall from your project that there is both a DiscountExtender and a PriceProvider. if this "copy order" occurs in the frontend, then both the PriceProvider and the DiscountExtender will evaluate the cart when loaded. So if you are confident that both of these are in place and functional, you ought to be home-free.

BR
Snedker

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

There is an example in the API docs:

https://doc.dynamicweb.com/apix/api/Dynamicweb.Ecommerce.Prices.PriceProvider.html

What you have to ensure is that you implement the PreparePrices method of the priceprovider - it will be called with all the products that are about to be price calculated, and then you can look up the prices for the current user (user is part of the price context). You can choose to cache the prices - or just look them up each time. 

You lookup discounts - and prices and discounts are 2 different things in DW. So you may not need to lookup the price, but lookup the discount instead? If the price is always the same, but discount is different - it is another scenario than the price is different for each customer. Effectively it is the same, but conceptual it is different - is the price 100 - 10 discount or is the price 90?

BR Nicolai

 

You must be logged in to post in the forum