Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Matt,
How would I go about setting a discount as inactive programatically?
I've tried to use .GetDiscount but this only returns DiscountReadOnly which I can't edit or save.
Thanks Ben
Hi Ben,
All Vendr's APIs return read only entities by default, you need to make it writable to edit it. You can find info on read only and writable entities, and how to make a read only entity writable here https://vendr.net/docs/core/1.8.0/key-concepts/readonly-and-writable-entities/
Ultimately, you'd need something like
using(var uow = _vendrApi.Uow.Create()) { var discount = _vendrApi.GetDiscount(discountId).AsWritable(uow) .SetActive(false); _vendrApi.SaveDiscount(discount); uow.Complete(); }
Matt
Perfect, thanks Matt.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Setting Discount as inactive programatically
Hi Matt,
How would I go about setting a discount as inactive programatically?
I've tried to use .GetDiscount but this only returns DiscountReadOnly which I can't edit or save.
Thanks Ben
Hi Ben,
All Vendr's APIs return read only entities by default, you need to make it writable to edit it. You can find info on read only and writable entities, and how to make a read only entity writable here https://vendr.net/docs/core/1.8.0/key-concepts/readonly-and-writable-entities/
Ultimately, you'd need something like
Matt
Perfect, thanks Matt.
is working on a reply...