Page 3 of 3

Re: Add to Cart, with Multiple Variants - how?

Posted: Thu Dec 18, 2014 7:41 am
by simonmlewis

Code: Select all

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="custom" value="575757575">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="youremail@mail.com">
<input type="hidden" name="currency_code" value="US">

<input type="hidden" name="item_name_1" value="beach ball">
<input type="hidden" name="amount_1" value="15">

<input type="hidden" name="item_name_2" value="towel">
<input type="hidden" name="amount_2" value="20">

<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
It then stores that 575757575 in the Cart DB Table by each item under cart_id. And when ti comes back, it assigns that Cart ID as paid.
And I guess when they despatch it, it will mark is as depsatched. Or a despatched field.

In your opinion, is this a better way of doing it, than important something like X-Cart?

Is a listener very important? I guess it's whether or not one feels these items values will be "messed with" by someone who knows what they are doing.

Re: Add to Cart, with Multiple Variants - how?

Posted: Thu Dec 18, 2014 8:32 am
by Celauran
Doesn't matter if the values are messed with. They're your products. You know what the prices are. If what you get back from PayPal doesn't match, if the prices are off, don't process the order.

Re: Add to Cart, with Multiple Variants - how?

Posted: Thu Dec 18, 2014 8:36 am
by simonmlewis
And just refund with a note saying something or other. Cool.
So what about Sage... any ideas?

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 3:50 am
by simonmlewis
How do I post this kind of XML through a <form>? This is the kind aof thing Sage would need posted through.

Code: Select all

<basket><agentId>johnsmith</agentId>-<item><description>DVD 1</description><productSku>TIMESKU</productSku><productCode>1234567</productCode><quantity>2</quantity><unitNetAmount>24.50</unitNetAmount><unitTaxAmount>00.50</unitTaxAmount><unitGrossAmount>25.00</unitGrossAmount><totalGrossAmount>50.00</totalGrossAmount><recipientFName>firstname</recipientFName><recipientLName>lastname</recipientLName><recipientMName>M</recipientMName><recipientSal>MR</recipientSal><recipientEmail>firstname.lastname@test.com</recipientEmail><recipientPhone>1234567890</recipientPhone><recipientAdd1>add1</recipientAdd1><recipientAdd2>add2</recipientAdd2><recipientCity>city</recipientCity><recipientState>CA</recipientState><recipientCountry>GB</recipientCountry><recipientPostCode>ha412t</recipientPostCode><itemShipNo>1123</itemShipNo><itemGiftMsg>Happy Birthday</itemGiftMsg></item><item><description>DVD 2</description><productSku>TIMESKU</productSku><productCode>1234567</productCode><quantity>1</quantity><unitNetAmount>24.99</unitNetAmount>
<unitTaxAmount>00.99</unitTaxAmount><unitGrossAmount>25.98</unitGrossAmount><totalGrossAmount>25.98</totalGrossAmount><recipientFName>firstname</recipientFName><recipientLName>lastname</recipientLName><recipientMName>M</recipientMName><recipientSal>MR</recipientSal><recipientEmail>firstname.lastname@test.com</recipientEmail><recipientPhone>1234567890</recipientPhone><recipientAdd1>add1</recipientAdd1><recipientAdd2>add2</recipientAdd2><recipientCity>city</recipientCity><recipientState>CA</recipientState><recipientCountry>GB</recipientCountry><recipientPostCode>ha412t</recipientPostCode><itemShipNo>1123</itemShipNo><itemGiftMsg>Congrats</itemGiftMsg></item><deliveryNetAmount>4.02</deliveryNetAmount><deliveryTaxAmount>20.00</deliveryTaxAmount><deliveryGrossAmount>24.02</deliveryGrossAmount><shipId>SHIP00002</shipId><shippingMethod>N</shippingMethod><shippingFaxNo>1234567890</shippingFaxNo></basket>
EDIT: Am trying this solution but I cannot see how you POST in a form, that firings of data in the header to the Sage page URL.
http://www.codediesel.com/php/posting-xml-from-php/

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 6:52 am
by Celauran
In all likelihood, you don't. Why do you think this needs to be done via a form?

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 7:09 am
by simonmlewis
Honestly... no idea. I've never ever done this with XML before.
I dont' know what has to go where.
I've only ever done it in normal form fields.

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:10 am
by Celauran
You haven't really mentioned what any of this is for. I'm going to guess you're trying to capture form data from a user and then relay that to Sage in the XML format they require. Nothing says that needs to be a single step. Why not submit the form to somewhere on your own site, process the form as needed, build up your XML, and then use Guzzle to send it to Sage?

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:14 am
by simonmlewis
This would be a cart. so a cart page shows everything in the cart. If they opt for PayPal, it would sho wa PayPal buy now type button. If they opt for Sage, it would show a Sage buy now button which would "somehow" post the XML to Sage. It's that last bit I am trying to understand.

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:32 am
by Celauran
See my previous post, then. Post the form to a processing function, then send it out from there.

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:35 am
by simonmlewis
I had a little at Guzzle, and I cannot make head nor tail of it.
I guess I need to learn it. to say "post the form to a processing function then send it out from there", means nothing to be at this stage, sadly!

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:44 am
by Celauran
Instead of pointing your form's action to Sage, point it somewhere on your own site. Perform whatever processing you need to do there -- extract values, create XML, etc -- and then use Guzzle (or cURL, if you prefer) to send a POST request to Sage's endpoint.

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:50 am
by simonmlewis
Does this happen via Ajax? Or does the external file then direct the user to Sage?

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 9:58 am
by Celauran
Couldn't tell you. I have never used (or even heard of) Sage. Given that they're expecting XML, I'd assume you'd already have collected user information but that leaves you handling credit cards. Best to consult their documentation.

Re: Add to Cart, with Multiple Variants - how?

Posted: Mon Jan 05, 2015 5:39 pm
by Christopher
simonmlewis wrote:Does this happen via Ajax? Or does the external file then direct the user to Sage?
It wouldn't happen via Ajax. When the page makes a request to your server (via link, form submit or Ajax) that script uses Guzzle/cURL to make a request to the Sage server with XML it generates. Guzzle/cURL returns the response from Sage to the script which inspects the result and generates a page for the user as appropriate.