TransWikia.com

How to use a php hook to pull data into PayPal from Simple Cart

ExpressionEngine® Answers Asked on October 3, 2021

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="[email protected]">
<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>

One Answer

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?

Answered by JCOGS Design on October 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP