lunar icon indicating copy to clipboard operation
lunar copied to clipboard

Feat - Discounts

Open alecritson opened this issue 2 years ago • 3 comments

This is an initial PR to get discounts started in the core...

alecritson avatar Jun 21 '22 07:06 alecritson

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
getcandy-2-docs ✅ Ready (Inspect) Visit Preview Dec 13, 2022 at 1:48PM (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview Dec 13, 2022 at 1:48PM (UTC)

vercel[bot] avatar Jun 21 '22 07:06 vercel[bot]

I've had a quick look through this and it all looks promising so far. One use case that we would have would be setting an entire brand or category on discount... from what I'm seeing that would mean adding every purchasable in those brands, which could be unwieldy. Would it be an option to change how you work out what items the discount applies to, so that a developer can write some custom logic to determine that?

ryanmitchell avatar Jun 27 '22 06:06 ryanmitchell

I've had a quick look through this and it all looks promising so far. One use case that we would have would be setting an entire brand or category on discount... from what I'm seeing that would mean adding every purchasable in those brands, which could be unwieldy. Would it be an option to change how you work out what items the discount applies to, so that a developer can write some custom logic to determine that?

We did intend to allow Collections to be added also. As for Brands, I guess it could be possible, but we're just trying to get an MVP out there. You can make your own discount types if you need something specific.

glennjacobs avatar Jun 27 '22 07:06 glennjacobs

Looks good, but I found a few issues/concerns.

  • When saving a discount it flashes the notification but immediately refreshes the page.
  • Errors at the top of the form are not clear when trying to save a discount.

Few points here.

  • Why is the "Priority" input so big?
  • We need an explanation of what "Priority" is. It's not obvious, especially for non-developers.
  • It would be helpful to have a way to view the current priority list.
  • "Stop" is misleading. It looks like it will stop the discount.
  • The word "propagating" is confusing, it needs a non-developer explanation. Something like...

Checking this will prevent other discounts from being applied if the current discount criteria is matched.


The UI is a little wonky here. It looks like some classes are missing on the parent, possibly p-2 space-y-2.


  • Show which discounts are active based on the date.
  • Add sorting for date and status (active/inactive/scheduled).
  • I don't think "Stop" is needed.

Adding a "Select All" could be handy, especially if there are lots of collections/brands.


The active button is invisible.


More of a generic issue across the hub, but the error icon overlaps the spinners in the number input.

markmead avatar Nov 15 '22 10:11 markmead

Feedback...

We want to split the edit screen into 3 sections. The general information, e.g. name, handle, discount type, etc. Then the conditions for the discount, and then finally the rewards. We should break it up into separate panes to indicate this, as it's quite a full-on form currently.

Coupons should be part of the generic conditions for a discount. A discount should either automatically apply or be applied by a matching coupon.

Discount types should be "Buy X Get Y" or "Discount".

Buy X Get Y

This is the typical BOGOF type promotion. You can state which products you need to buy to qualify, and state which products you can get for free. We need to update the Cart to list the available free products (I did something before on a previous PR we closed). The free products should be grouped by the qualifying discount so that customers can easily apply them to their cart. If a customer already has a qualifying product in their cart, then they get it for free. If they remove it or don't apply a free product, then they simply won't get it.

Discount

This gives a % off the cart if the conditions are met. It may only discount certain products in the cart, or all products in the cart. We currently allow for a fixed amount off, if we're doing that it will need to be multi-currency. We also need to be careful that fixed amounts don't make something too cheap, free or even a negative amount. I guess there is an onus on the store owner to ensure the logic is correct, but we certainly should never have a negative number.

Misc. Feedback

The "min. cart amount" field is far too wide and it should also default to "0". In fact, there are a LOT of very wide inputs, which makes it hard to see what is expected.

E.g. image

There are no conditions for channels and customer groups, we'll need those.

Do we need to consider reporting on how many times a discount has been used?

glennjacobs avatar Nov 17 '22 15:11 glennjacobs

hello , I found an error in this branch ... it happens when I perform a clean install

error: "Foreign key constraint is incorrectly formed"

explanation: the error happens because the "brand_discount" table asks for a primary key "brand_id" that does not yet exist

how I fixed: simply renamed the "brand_discount" migration to migrate after the "brands"

AlessandroAmos avatar Nov 17 '22 19:11 AlessandroAmos

@glennjacobs I've pushed a bunch of updates to the UI. Hopefully you should be able to pull down without any issue, but if there are problems let me know. it's a WIP atm.

alecritson avatar Nov 18 '22 13:11 alecritson

Generally a great improvement. Here are my thoughts...


image That is far too wide for a qty value.
image Should be called "Discount" & "Buy X Get Y"

I think inputs should always have default values where possible.


image I think that would be nicer with a toggle, rather than just leave it blank.

Collections are not grouped by "Collection Group", might get a little confusing.


image Needs a little spacing above "Euro"
image Far too wide and could do with a "%" on the input. Same for price inputs, far too wide.

glennjacobs avatar Nov 18 '22 13:11 glennjacobs

@alecritson
the migration error still exists but now because of the "discounts" table

image

to fix it I renamed the discounts migration 2022_11_18_100000_create_discounts_table.php to 2022_06_16_100000_create_discounts_table.php

image

AlessandroAmos avatar Nov 18 '22 14:11 AlessandroAmos

a suggestion....

I believe that when there are several registered brands or collections, it can end up creating a rather large scroll, making it difficult for the end user

make this image

more like this: image

AlessandroAmos avatar Nov 18 '22 22:11 AlessandroAmos

image Migrations issue.


image Can we put "Priority" under the name/handle pane?
image Can we have more than 2 priorities? Even if it's just adding medium setting?
image Use 2 columns for name and handle.
image Nothing done to separate Collection Groups in the selection box.
image Switching currency causes an error.
image Do we need to say "Leave this blank for unlimited uses."?

Validation doesn't show what's missing/wrong. E.g. not adding any Qualifying Products.

glennjacobs avatar Nov 22 '22 14:11 glennjacobs

image

Can it be

"Qualifying Products"

"Product Rewards"

?

glennjacobs avatar Nov 22 '22 15:11 glennjacobs

image Can we give the placeholder a grey background, perhaps along the lines of the image upload box? At the moment it looks too close to an input box.

glennjacobs avatar Nov 22 '22 18:11 glennjacobs

image Setting max uses and then unsetting it causes this error.


image Changing between "Percentage" and "Fixed Amount" clears the "Minimum cart amount" for some odd reason.
image Selecting a (minimal) product causes this error.
image The placeholder "No products currently selected" doesn't have the `bg-gray-50` background color.

No validation error if no products are selected on a "Buy X Get Y" discount type.


Validation errors display in the Discount Type pane, but the menu on the right doesn't indicate this by showing the menu item in red.


image No warning if a discount has no availability like products do.

glennjacobs avatar Nov 24 '22 12:11 glennjacobs

No validation on "Percentage" or "Fixed Amount" inputs.

glennjacobs avatar Nov 24 '22 14:11 glennjacobs

image Validation issue when using fixed price. Weirdly I can't reproduce it again.


Can we use the titles

"Qualify Products" & "Product Rewards"

?


How about showing the discount type on the index datatable?

glennjacobs avatar Nov 25 '22 14:11 glennjacobs