so NetSuite tells me that support for a variable a...
# suitecommerce
f
so NetSuite tells me that support for a variable amount (like a donation) is an 'enhancement request' for SC and SCA. Does anyone know of a workaround? Seems like a very basic thing to be missing from a web platform
l
I'm not an authority on the pros and cons or other context of this method, but there is backend url for adding items to cart via ajax. Something like: '/app/site/backend/additemtocart.nl?c={accountid}&n=1&buyid={itemid}&qty={quantity}&amount={itemprice}'
k
I have not been able to get variable amounts to work from the front end. It's been a while since I last tried though.
p
LMG approach works, remember to check the "Variable Amount" checkbox on the item record.
👏🏻 1
🙂 1
f
What is the LMG approach?
n
This above one @LMG sent
'/app/site/backend/additemtocart.nl?c={accountid}&n=1&buyid={itemid}&qty={quantity}&amount={itemprice}'
c
Though a very powerful platform, few things in SCA are simple. Happy Friday.
s
FWIW, I believe this is because the Commerce API does not support the
amount
property when adding items to the cart and so even if you were to pass an amount to the SuiteScript, it would always be ignored. As for what LMG suggested, that is a legacy WSDK endpoint. It is supported for the timebeing and while you have Site Builder and WSDK activated on your account. Those endpoints will be deactivated if you stop licensing those products. But yes, it should be possible to write a customisation for SCA that uses that end point and looks reasonably like any other product on the site.
f
so there's no way it can be done with SCS? it will always ignore the variable amount field and pull the price from the item record?
Also, I tested the addtocart URL on an account with SC only (no sb or wsdk) and it basically worked, allowing me to set the price in the GET request. I'd rather not build out a workaround that is officially not supposed to work, but it'd sure be nice to be able to match basic SB functionality.
s
Variable amounts are not supported in the commerce API and there is no SuiteScript way to add items to the cart
f
That's pretty confusing... this account never had SB but this url works fine to add that item to the cart, and it lets me set any price I want, which is then preserved in the cart/checkout: https://store.sths.org/app/site/backend/additemtocart.nl?c=3452006&n=1&buyid=370&qty=1&amount=40.11 Is it a bug that this works? I thought SB also uses the commerce API, which would mean that it has to support variable amount items, and it sure seems to...
s
OK I checked and you're right; additemtocart is not dependent on SB/WSDK. Other endpoints are but not that one
Stuff that is based on app/site/query looks to be but not app/site/backend
I don't know enough about SB (clearly) to say whether it uses the commerce API
f
I don´t think amount is something that you can use as a parameter, at least is not documented, but you could try it