0

I was wondering how to connect Simple Cart add-on to PayPal using the PHP hooks.

I'm new to using hooks, but would appreciate an example to get me going. I would like to display the 'price', 'qty' and 'entry_id' for an item and pass these to PayPal 'Buy Now' button form code, if that's the correct way.

https://docs.reinos.nl/simple-cart/#php-api

<?php 
ee()->load->add_package_path(PATH_THIRD . 'simple_cart/');
ee()->load->library('simple_cart_api');
ee()->load->remove_package_path(PATH_THIRD . 'simple_cart/');

//save_cart_entry
ee()->simple_cart_api->add_cart_entry($entry_id = 0, $price = 0, $qty = 1, $tax = 0, $time = 1200, $extra_param = array(), $increment = true);
?>

<form action="https://www.paypal.com/au/cgi-bin/webscr" method="post" target="paypal">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="info@wabisabi-press.co.uk">
<input type="hidden" name="currency_code" value="UKP">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="add" value="1">
<input type="hidden" name="amount" value="">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="undefined_quantity" value="">
<input class="cart-btn cart-btn-secondary small_hide mr-2" type="submit" name="buy_now" id="buy_now_265" value="Buy Now">
</form>
0

The documentation for simple-cart indicates that in order to add an entry to the cart you would need to already know the entry_id, price and quantity of the item you want to add to the cart.

Since presumably these would be held in php variables already, and I'm guessing you would use these variables in the add_cart_entry call, can you not simply add these values to the paypal form too?

| improve this answer | |
  • 1
    Many thanks for your reply. The issue was that the PayPal code was a form and so is 'Simple Cart'. Therefore you can't have a form within a form. The new API from PayPal uses a JS button and therefore I can now use the normal 'Simple Cart' tags. – Graham Jun 17 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.