Jump to content
Peter Knight

Foxycart - Inject field data

Recommended Posts

I have two basic text fields called Product and Price.

According to FoxyCart docs, I can manually create a URL as follows which will add a Picture Frame worth 100 dollars to my cart.

<a href="https://YOURSTORE.foxycart.com/cart?name=PictureFrame&price=100">Add picture frame</a>

Is there a way to swap out the product and price for the values in my fields? I've tried the following but it never converts my fields into actual data

<a href="https://YOURSTORE.foxycart.com/cart?name=<?php echo $page->product; ?>&price=<?php echo $page->price; ?>Add picture frame</a>


There are some errors in the formatting above but you get my thinking. Typing on ipad

Share this post

Link to post
Share on other sites


You should pass the values from $page->product through a url sanitizer. If there are any spaces in the product field you'll get a dud url doing it like that.

$url = wire()->sanitizer->url($page->product);

You could pass the price field through the sanitizer too - no harm in that.

  • Like 1

Share this post

Link to post
Share on other sites

I don't know if that will fix your exact problem - it might if your product field has a space in it.

I do know that the way you are outputting a user-supplied field as part of a URL could generate invalid URLs. For example, If a user ever entered anything other than a-z, A-Z, 0-9, _, -, ~ or . in your product field you could find yourself with a potentially troublesome url - especially if that field had an '&' in it. If that were the case and you keep constructing the urls like that you'll find there's an extra get parameter for each '&' in your product field; probably not what you want.

More on wikipedia.

Share this post

Link to post
Share on other sites

Quick update. If you're running the latest version of FoxyCart, embedding field values in FC links will work.

When I originally posted, I think FC was running a slightly older version. 

  • Like 1

Share this post

Link to post
Share on other sites

Hey Guys,

I got one more question about foxycart: How did you get your quantity value into the foxycart link?

Do you have a best practice for the &quantity=XX ?

Thank you!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jeannette
      Hello Fellows,

      I have a wonderful webshop, using PL and Padopt, a module developed by Julien Vaubourg and highlighted in ProcessWire Newsletter. Here is our shop: cheval-ami.fr
      I am looking for a new developer, helping me to keep the shop smooth and up to date.
      We would like to improve automated invoicing and worldwide shipping, getting DHL integrated and give people the possibility to create their personal accounts and be the nicest shop in the equine industry. We are still a young company, working all in german, english and french. We are very interested in a long time, kind and friendly relationship without any stress, but reliable reactivity in case of urgency. 
      We are based in Hamburg and near Paris and would prefere to work with somebody who is available to catch up around a table, at least sometimes.
      Contact: mail@cheval-ami.fr or +33 626 22 1000 or +49 170 20 28 215
      Thank you, Have a beautiful day,
    • By Marco Ro
      Hi everyone,
      a year ago we had put online a first version of our website, which didn't satisfy me much and had several bugs. This year I started working on a complete restyling, both in terms of functionality and graphic. I am very happy with the result obtained. Finally, last week we put this version online that I am proud to show you!
      Site EU: https://www.playwood.it/
      Site USA: https://www.us.playwood.it/
      It is an eCommerce for a small StartUp, the PlayWood, based in Reggio Emilia, Italy.
      The site is multilingual, has two areas of purchase and has two levels of registration. Redirectory based on the source IP for the USA customer and preferred language in the browser for the others countries. It has systems for use registration and sending emails dependent on specific actions, like: registration, purchase, request for quotes, information request, etc. Through the API the site communicates with external platforms such as the management software, Mailchimp and other systems to support marketing and company operations. 
      The site is constantly evolving, in the future we intend to add new features.
      The site was created with these modules:
      Padloper  Login/register Media Library ProCache PayPal Checkout Subscribe to Mailchimp Tracy Debugger Cookie Management Banner Continent and country names ImagePicker Field Map Marker External libraries:
      Spectre, scss framework Swiper slideshow verlok/lazyload fancybox
      Creating this site with ProcessWire represented a moment of strong professional growth. When I started I had little knowledge of some types of language, but Processwire and its APIs give me the ability to easily build pages, manipulate data and integrate any external library easily. Thus, I was able to deepen my knowledge more and more. So I wanted to thank the creators of the cms, who keeps it and who implements it, obviously all the people in the forum for the help they gave me, was very important.
      Thank you!


    • By benbyf
      Not new, but a website I've worked on for a year or so in continous development.
      I originally inherited the site from another web design company - upgraded PW and over the year added ecommerce using the Stripe module and a custom integration, revamped the frontend and added lots of new templates.
      Also did some frontend work on the shopify shop.

    • By kuba2
      I need to make a small, easy Webshop for a friend. He is selling 4 music albums.
      What would be the best way to go?
      Is there a sensible solution for a webshop within processwire? 
    • By prestoav
      Hi folks,
      I have a marketplace site built on PW which I'd like to tie to a subscription payment system for those selling. The user accounts currently use specific PW user accounts. I'm looking closely at PayWhirl to manage payments and subscriptions as it looks ideal for subscriptions. Their API seems to work well too from initial testing.
      I wondered if anyone else in this super forum had used PayWhirl and had any advice or tips & tricks?
  • Create New...