The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Shipping as a product?

babblebibbabblebib Member
in Help edited January 2014
Is it possible to add shipping costs to the cart in the same way as you would with a product (i.e. a query string param).

I'm bypassing a lot of the default foxy 'add to cart' screens and building up my own cart which I pass to FoxyCart as one big form called 'checkout' on my cart summary screen. This give me a little more control over things like up-sell, analytics etc

I'd like to add shipping as one of the options on my own cart summary page, but want to make sure that appears in the foxy cart checkout page too.

I could set Foxy to free shipping and add it as a product from my own cart but that seems a bit pants.

  • fc_adamfc_adam FoxyCart Team

    I actually set this for a store I did some work on previously, using the tiered flat rate shipping snippet from the wiki, and passed in shipping values as hidden session values to the cart. This way the customer never saw the shipping value for each product, but received a total value on the checkout.

    Currently we don't support hidden attributes per product though (we will in a future version though) so for now the way to do it is by creating a parameter that uses the products code in it's name. For example, say you have a product called "Widget" with a code of "abc123", a price of $20 and that costs $5 to ship. Your add to cart would look like this:
    <input type="hidden" name="name" value="Widget" />
    <input type="hidden" name="price" value="20" />
    <input type="hidden" name="code" value="abc123" />
    <input type="hidden" name="h:shipping_abc123" value="5" />

    Then on your checkout on page load you would loop through the custom session attributes in the cart, looking for any that start with "shipping" and add together the shipping cost for each one. If you wanted to multiply that shipping value by the quantity of that particular product, you'd need to also loop through the products for each shipping value and find the product with the matching code. Finally you'd set the flat rate shipping amount like in the snippet, and the customer should then see their final shipping cost, without seeing what each individual product costs to ship.
Sign In or Register to comment.