Open adrienne opened 2 years ago
@fulopattila122 - help please!
(We are using specific modules rather than the whole framework, if that makes a difference to how we have to set things up.) Can we do this with Properties? The documentation on those is a little confusing as to how to set them up with only the Cart module.
No, properties won't help here. I'm afraid right now, you can only do this by changing the price of the product on the fly. This can be even temporary, without actually saving the price of the product to the DB.
A naive example:
class CartController
{
public function addItem(Request $request)
{
$product = Product::findBySku('DONATION');
$product->price = $request->get('amount_to_donate');
Cart::addItem($product);
return redirect()->to('/cart');
}
}
Nevertheless, I must admit that there should be an easier way provided by the cart module out of the box.
Our site allows donations of arbitrary amounts. Is there a way to make the price of a product variable?