Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discount per product? #58

Closed
Tazi0 opened this issue Oct 20, 2022 · 1 comment
Closed

Discount per product? #58

Tazi0 opened this issue Oct 20, 2022 · 1 comment

Comments

@Tazi0
Copy link

Tazi0 commented Oct 20, 2022

Is there a way to have a discount on a product? I've fumbled around with the ww.merx.cart & editing the price itself, but there doesn't seem a way to correctly apply the discount.

@tobiasfabian
Copy link
Member

Hi @Tazi0,

thanks for your question. In the first place, Merx only needs to know the price to be paid in the end (in your case, that would be the discount price). Any other price (e.g. the original price) is not relevant for Merx. It is only a question of the user interface, in the first place.

If you want to store the original price (e.g. to show the original price on the invoice) you can to pass the original price to the Cart::add() method as shown below.

Add item to cart

$productPage = page('bike');
$cart->add([
  'id' => $productPage->id(),
  'price' => $productPage->price(), // something like `$productPage->originalPrice() * 0.8` would be possible as well
  'originalPrice' => $productPage->originalPrice(),
]);

View cart

echo $cartItem->originalPrice()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants