Discount Code

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 anni tempo fa
Hello,

Please do you know, with Nop 3.90, where are stored (which table) the used Discount Code for the cart when the user has input it ?
When i take a look inside the shoppingcart table, there is no trace of a Discount.id  link to another table.

Thank you for your help
5 anni tempo fa
Hello,

I think they stored in cache and customer generic attribute.

Look at this method of discountservice GetAllDiscountsForCaching and this is SystemCustomerAttributeNames.DiscountCouponCode generc attribute.

Hope you will understand..!!
5 anni tempo fa
Hi ,

you can track your discount usage history from
this table : [DiscountUsageHistory]

hope so it can helpful to you

Thanks
5 anni tempo fa
Thank you very much all
5 anni tempo fa
but if I can go further

- answer from ilyaspatel: The table [DiscountUsageHistory] contains only the discount codes used after the confirmation of the sale, but not the discount codes in use in the basket not yet validated.

- answer from sk5202: Regarding discount codes currently in use in the shopping cart (and that would be saved in cache) and not in a table:
I do not understand how we can find the whole cart with the current discount codes, after logoff, kill applications and emptying the cache ?
5 anni tempo fa
Correct, The table [DiscountUsageHistory] is not relevant to your question about current discount in cart.  As the name implies, it records Discount Usage History ;)

GetAllDiscountsForCaching is also not relevant.  It caches the discount configuration (admin settings)

The Generic Attributes for Customer is where the discounts are 'cached' for the customer's current cart.


\Libraries\Nop.Services\Customers\CustomerService.cs
        public virtual string[] ParseAppliedDiscountCouponCodes(Customer customer)
        {
            if (customer == null)
                throw new ArgumentNullException(nameof(customer));

            var existingCouponCodes = _genericAttributeService.GetAttribute<string>(customer, NopCustomerDefaults.DiscountCouponCodeAttribute);
5 anni tempo fa
Tank you NewYork,

But, as i said above, even when you clear the cacheand and restart the applications,

the cart with the discount number is allways concerved, so there is definitly a table for that ?  that is what i looking for, for analysing and managing ?

Regards
5 anni tempo fa
Check the GenericAttribute table please. The bellow query may help you.


SELECT [Id]
      ,[EntityId]
      ,[KeyGroup]
      ,[Key]
      ,[Value]
      ,[StoreId]
  FROM [othoba].[dbo].[GenericAttribute]
  where [Key] like '%DiscountCouponCode%'
5 anni tempo fa
Great, it's what i was looking for

Have a good day.

Michel
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.