FreewayTalk
7 replies to this thread. Most Recent
SteveB
10 Mar 2010, 10:51 am
[Pro] Add Quantity to cart Mals Ecom with php
Hi All,
I’ve been having a bit of trouble getting a quantity field to add the quantity to the cart on mals.
I’m not using any of the Shopping actions as the products details are all held on the server in a couple of databases and are downloded to the webpage using a combination of php, MySQL and the php block action to build the table of products on the page. The quantity field is in this block with the Name field set to “myQty” and the Value field to “$myQty”.
The product details, price, return url etc. are added to the cart via the url to the cart, each product has it’s own unique data which is set up in a “Buy” link via php as in this example:
<A HREF='http://ww5.aitsafe.com/cf/add.cfm?userid=00000000&product=$myPartnumber%20$myDescription&qty=$myQty&discountpr=$myDiscprmat&units=$myWeight&return=$return' TITLE='Add to Order - $myPartnumber $myDescription $myQty'> Buy </A>
The page with the test set-up is here:
On Product and Section pages and only these menu sections/items have been set up to work on the pages: JCS Clips, Hydraulic Adaptors (up to Metric Male > Locknut) Gates Hose, Gates Hydraulic (up to & incl Megacrimp Flat Face).
These pages also test the discount structure that you can see on the page (under List Price & Quantity Disc).
If you input 10 into the qualtity colunm and press the buy button, only 1 will be added to the Shopping Cart.
Try as I might, I can’t seem to get it to work correctly if at all. It probably is something simple, but at the moment my brain doesn’t work in simple mode, (no chance for complex then!).
Any suggestions gratefully received.
Best wishes,
Steve.
SBDesign
Design • Artwork • Illustration
SteveB
10 Mar 2010, 3:10 pmHi,
Me again!
Still can’t get this to work…
All I want to do is get the quantity input in the browser to attach to the “Buy” url link to mal’s shopping cart, so that it is included with the other variables.
At the moment unless I set the quantity variable to 1 in the php block action it doesn’t send anything to the cart because the variable qty is empty. You can change the quantity but it doesn’t update on the link.
I need this to work so that customers can input the quantity they want before they press the “Buy” link.
Any thoughts gratefully received…
Thanks in anticipation.
Steve.
SBDesign
Design • Artwork • Illustration
Tim Plumb
10 Mar 2010, 7:48 pmHi Steve, There are a couple of things that are missing here for this to work properly; 1. The text link has no way of getting to the quantity value the user has entered for the product without first submitting the page. You ‘could’ get the figure using javascript but that would be at best a hack and would be prone to failure. 2. For GET requests like text based buy links you need to make sure that your data is correctly encoded. This means using urlencode in PHP to make sure the spaces and any other special characters are all encoded before you use the data.
Having said all of this I would recommend that you swap your buy text links for forms. They are just as easy to set up as text links, are a bit easier to read (and therefore debug) and can use the user specified values for the product quantities. Have a look at the following example HTML page. It should give you an idea of how to lay out your forms. http://www.freewayactions.com/code/?f=mals-example.html
Regards, Tim.
On 10 Mar 2010, at 16:10, SteveB wrote:
All I want to do is get the quantity input in the browser to attach to the “Buy” url link to mal’s shopping cart, so that it is included with the other variables.
At the moment unless I set the quantity variable to 1 in the php block action it doesn’t send anything to the cart because the variable qty is empty. You can change the quantity but it doesn’t update on the link.
I need this to work so that customers can input the quantity they want before they press the “Buy” link.
Any thoughts gratefully received…
FreewayActions.com - Freeware and commercial actions for Freeway Express & Pro. ………………………………………………………………………… Protect your mailto links from being harvested by spambots with Anti Spam. Only available at FreewayActions.com ………………………………………………………………………… http://www.freewayactions.com
chuckamuck
10 Mar 2010, 9:17 pmHoly frejole! Freeway.com code store? Awsome!
Freeway Pro 5, G4 Powerbook 1.33 ghz 1.25gb ram, 2.3 ghz Dual Core MacPro 10gb ram
waltd
10 Mar 2010, 9:24 pmTim Plumb FTW!
Walter
On Mar 10, 2010, at 5:16 PM, chuckamuck wrote:
Holy frejole! Freeway.com code store? Awsome!
Freeway user since 1997
Tim Plumb
10 Mar 2010, 9:40 pmI initially read that as WTF! :-) I’m uncertain which of these meanings is correct in this context; http://www.acronymfinder.com/FTW.html … although I suspect it’s ‘Feel the Wind’!
The code store started off as this simple PHP code listing script; http://www.freewayactions.com/code/?f=phpsourcecodelister.php
As I’ve had time to extend it I’ve added the features that I’ve found useful for myself (downloads, url shrinking and print style sheets) and have a to-do list as long as my arm of things that I can learn about while tinkering with it. My grandfather was an engineer and although he didn’t like driving much he was never happier than when he was pulling his car to bits. :-) Regards, Tim.
On 10 Mar 2010, at 22:24, Walter Lee Davis wrote:
Tim Plumb FTW!
Walter
FreewayActions.com - Freeware and commercial actions for Freeway Express & Pro. ………………………………………………………………………… Protect your mailto links from being harvested by spambots with Anti Spam. Only available at FreewayActions.com ………………………………………………………………………… http://www.freewayactions.com
waltd
10 Mar 2010, 9:45 pmFor The Win. Meaning, “Advantage, Mr. Plumb.”
Walter
On Mar 10, 2010, at 5:40 PM, Tim Plumb wrote:
I initially read that as WTF! :-) I’m uncertain which of these meanings is correct in this context; http://www.acronymfinder.com/FTW.html … although I suspect it’s ‘Feel the Wind’!
The code store started off as this simple PHP code listing script; http://www.freewayactions.com/code/?f=phpsourcecodelister.php
As I’ve had time to extend it I’ve added the features that I’ve found useful for myself (downloads, url shrinking and print style sheets) and have a to-do list as long as my arm of things that I can learn about while tinkering with it. My grandfather was an engineer and although he didn’t like driving much he was never happier than when he was pulling his car to bits. :-) Regards, Tim.
On 10 Mar 2010, at 22:24, Walter Lee Davis wrote:
Tim Plumb FTW!
Walter
FreewayActions.com - Freeware and commercial actions for Freeway Express & Pro. ………………………………………………………………………… Protect your mailto links from being harvested by spambots with Anti Spam. Only available at FreewayActions.com ………………………………………………………………………… http://www.freewayactions.com
Freeway user since 1997
SteveB
11 Mar 2010, 10:27 amHi Tim, I like the freewayaction.com code page, another resource! Thanks for the info and your thoughts. I was leaning to that conclusion to use forms. I replaced the Buy link, which was a mark-up item, with all the form details in the same mark-up item, replacing the “hard wired” bits with php variables. A bit of tweaking with some of the variables to take out the url encoding and also enclose the php variables in single quotes, all now works! Just need to find out the best way to centre the form bits in the mark- up item, and to style them as I want… You can see the result here: <http://www.cotswoldengineeringsupplies.co.uk/2010-dev/Test_Discount/testproductpage.php?item=WDHCZP&inthere=&line=JCS%20Hose%20and%20P%20Clips >
Best Wishes, Steve.
On 10 Mar 2010, at 20:47, Tim Plumb wrote:
Hi Steve, There are a couple of things that are missing here for this to work properly; 1. The text link has no way of getting to the quantity value the user has entered for the product without first submitting the page. You ‘could’ get the figure using javascript but that would be at best a hack and would be prone to failure. 2. For GET requests like text based buy links you need to make sure that your data is correctly encoded. This means using urlencode in PHP to make sure the spaces and any other special characters are all encoded before you use the data.
Having said all of this I would recommend that you swap your buy text links for forms. They are just as easy to set up as text links, are a bit easier to read (and therefore debug) and can use the user specified values for the product quantities. Have a look at the following example HTML page. It should give you an idea of how to lay out your forms. http://www.freewayactions.com/code/?f=mals-example.html
Regards, Tim.
On 10 Mar 2010, at 16:10, SteveB wrote:
All I want to do is get the quantity input in the browser to attach to the “Buy” url link to mal’s shopping cart, so that it is included with the other variables.
At the moment unless I set the quantity variable to 1 in the php block action it doesn’t send anything to the cart because the variable qty is empty. You can change the quantity but it doesn’t update on the link.
I need this to work so that customers can input the quantity they want before they press the “Buy” link.
Any thoughts gratefully received…
FreewayActions.com - Freeware and commercial actions for Freeway Express & Pro. ………………………………………………………………………… Protect your mailto links from being harvested by spambots with Anti Spam. Only available at FreewayActions.com ………………………………………………………………………… http://www.freewayactions.com
Steve Ballinger SBDesign Design Artwork Illustration & Websites Providing Graphic Design since 1989 email: email@hidden phone: 01452 862966 mobile: 07889 715276
SBDesign
Design • Artwork • Illustration
