Hi,
The cardcmd command seems to be able to add inactive products to a shopping card. Instead of firing an error message the cardcmd command just adds the non active product to the shopping cart.
Kind regards,
Ben
Hi,
The cardcmd command seems to be able to add inactive products to a shopping card. Instead of firing an error message the cardcmd command just adds the non active product to the shopping cart.
Kind regards,
Ben
Hi Oleg,
Thanx, for looking into this issue, the client is not yet running the latest version. So an upgrade will probably solve this issue.
Kind regards,
Ben
Sorry but the issue is still there in DW 9.4. The code of the site you used for the demo is somehow correcting this issue.
I think the CartCmd should never be able to add an inactive product to the cart or at least make it configurable, adding an inactive product through the API is ok that is the responibility of the code that manipulates the order. But imho it should not be possible through the cartcmd. I fixed the issue for this client by adding an emergency break through a notification subscriber that deletes the added order line if the product is inactive.
Hi Ben
There is no exception if inactive products are added to the cart. But they are removed again on the next cart load. I.e. going to the checkout.
You can add a notification subscriber and fire an exception if required:
[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Added)]
public class EcomCartLineAddedObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
{
public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
{
if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs))
return;
Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs added = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.AddedArgs)args;
if (!added.AddedLine.Product.IsActive)
{
throw new System.Exception("Cannot add inactive products");
}
}
}
Hi Nicolai,
Sorry for the slow response, I fixed it with a notification subscriber. But this is not the behaviour I noticed. Actually we use inactive products in the same solution for some special addon product that we only add programatically with a calculated price, as far as I know these products are not deleted from the cart. (the notification subscriber has to know these products to make an exception for them).
Kind regards,
Ben
You must be logged in to post in the forum