Overriding the default price when adding to cart

General ShopSite user discussion

Overriding the default price when adding to cart

Postby Rgkopchak » Sat Jul 20, 2019 9:10 am

I am using a custom php site, and only utilizing the ShopSite cart. I pass the information to the cart via HTML form.

Is there anyway to directly override the default price, or will it ALWAYS use the set price in the SS database?

I've got the current code listed here (with the php variables changed).

Code: Select all
<input type="hidden" name="storeid" value="MYSTOREID" />
<input type="text" size="2" name="MYSKU:qnty" value="1" />
<input type="hidden" name="dbname" value="products" />
<input type="hidden" name="function" value="add" />
<input type="hidden" name="sku" value="MYSKU" />


Did some poking around the forum and was hoping adding this would work:

Code: Select all
<input type="hidden" name="MYSKU:price" value="OVERRIDEPRICE">


But no luck.

I am hoping to be able to change price dynamically at the this page level, rather then having to go through and change hundreds of prices in ShopSite.

Thanks for any help you can provide.

EDIT: After significant trial and error, here is what I found:

    1) There is a field in the SS product page "variable pricing" that must be checked for this to work.
    2) BUT if the price that is passed is less than the price set, it will default back to the original price.
    3) You can override this behavior by setting the price to zero.

This obviously isn't quite what I want, since I'd still have to go through and set everything to zero, and check the box for the items, and I want to do this dynamically.

Here is my thought:

    1) Turn Variable pricing on for all products.
    2) Set the price of ALL products to zero.
    3) Pass the price for ALL products via <input>, that way I can choose the price completely dynamically.

Can I get some confirmation that A) This will work as intended, and B) there isn't a better way?
Rgkopchak
 
Posts: 40
Joined: Wed Jul 28, 2010 7:45 am
Location: Missouri

Re: Overriding the default price when adding to cart

Postby loren_d_c » Mon Jul 22, 2019 9:44 am

Not allowing the variable price passed to the cart to be lower than the Price set for the product is the intended behavior, see:

https://help.shopsite.com/help/14.0/en-US/sc/pro/add.product.html

"Variable Pricing Check this box to enable variable pricing for this product. On your store's pages, the product price will be replaced by a text box the customer can fill in with the amount they want to pay. That amount will be compared with the product price (above), and will not be accepted if it is lower than the product price. You cannot put a variable price product on sale."

Note that the part about "the product price will be replaced by a text box the customer can fill in with the amount they want to pay" depends on the product template used, of course, and if you're not using ShopSite-generated store pages then it's not an issue at all, you can specify the price form field any way you want (pull-down, text field, hidden, etc).
loren_d_c
 
Posts: 2538
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere

Re: Overriding the default price when adding to cart

Postby Rgkopchak » Tue Jul 23, 2019 7:07 am

Hi Loren, thanks for the reply.

Can you confirm to me that this is the best way to accomplish what I am looking to do?

I don't use the product pages through shopsite at all. Just the cart. I want to be able to set the price myself, not use the default for the product.

1) Turn Variable pricing on for all products.
2) Set the price of ALL products to zero.
3) Pass the price for ALL products via my custom HTML <input type="hidden" name="MYSKU:price" value="OVERRIDEPRICE">, that way I can choose the price completely dynamically.

Is there a different (better) way other than the above?
Rgkopchak
 
Posts: 40
Joined: Wed Jul 28, 2010 7:45 am
Location: Missouri


Return to User Forum

Who is online

Users browsing this forum: Google [Bot] and 4 guests