Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > How to edit CMS.Ecommerce.ShoppingCartCleaner for all users View modes: 
User avatar
Guest
trheath - 10/31/2012 10:58:33 AM
   
How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Currently the scheduled task: CMS.Ecommerce.ShoppingCartCleaner only allows for anonymous users. How can I extend this functionality for all users?

Thank you

Tim

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/1/2012 7:45:36 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Hello.

This is compiled into dll so you cannot edit it.

You will need to write a custom scheduled task and perform this operation in API. In code-behind, you can get ShoppingCart objects e.g. via CMS.Ecommerce.ShoppingCartInfoProvider. GetShoppingCarts() method and then loop through this DataSet and delete particular Shopping cart objects via DeleteShoppingCartInfo() method.

Best Regards,
Radek Macalik

User avatar
Guest
trheath - 11/1/2012 8:14:05 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Thanks, I will give that a shot!

User avatar
Guest
trheath - 11/1/2012 8:36:42 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Hi Radek,

How do I return if the payment failed or not for each cart?

Thank you

Tim

User avatar
Guest
trheath - 11/1/2012 9:30:50 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Hi Radek,

Looks like I needed to use the OrderInfoProvider class instead for what I wanted to accomplish. I have a question though, which of these three methods do I need to use to delete an order:

DeleteOrderInfoInternal(OrderInfo)
DeleteOrderInfo(Int32)
DeleteOrderInfo(OrderInfo)

Thanks again for your help

Tim

User avatar
Guest
trheath - 11/1/2012 9:32:01 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Here's the code I'm using for the task (minus the delete functionality)

using System;
using System.Collections.Generic;
using System.Data;
using CMS.CMSHelper;
using CMS.Ecommerce;
using CMS.EventLog;
using CMS.Scheduler;

public class DeleteInvalidShoppingCartsTask : ITask
{
public string Execute(TaskInfo ti)
{
string detail = String.Empty;

List<OrderInfo> lstOrders = new List<OrderInfo>(OrderInfoProvider.GetOrders(CMSContext.CurrentSiteID));

foreach (OrderInfo order in lstOrders)
{
if (!order.OrderIsPaid)
{
detail += order.OrderInvoiceNumber.ToString() + " - " + order.OrderIsPaid.ToString() + "<br/>";
}
}

EventLogProvider.LogInformation("DeleteInvalidShoppingCartsTask", "Execute", detail);

return null;
}
}

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/12/2012 5:29:18 AM
   
RE:How to edit CMS.Ecommerce.ShoppingCartCleaner for all users
Hello.

As for the following methods:

DeleteOrderInfoInternal(OrderInfo)
DeleteOrderInfo(Int32)
DeleteOrderInfo(OrderInfo)


You should call DeleteOrderInfo instead of DeleteOrderInfoInternal, as DeleteOrderInfo calls its internal method anyway. If you already have an OrderInfo object, you can call DeleteOrderInfo(OrderInfo) directly. Otherwise you can call DeleteOrderInfo(Int32) and pass OrderID within.

Best Regards,
Radek Macalik