Skip to content

Instantly share code, notes, and snippets.

@tribulant
Created May 7, 2015 20:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tribulant/548d7d53cb0995a27a6a to your computer and use it in GitHub Desktop.
Save tribulant/548d7d53cb0995a27a6a to your computer and use it in GitHub Desktop.
WordPress Shopping Cart: Redirect/Hosted Payment Gateway step 6
// WordPress Shopping Cart: Redirect/Hosted Payment Gateway step 6
// http://tribulant.com/docs/wordpress-shopping-cart-plugin/7190
<?php
function process_order($order = null, $user = null, $params = null) {
global $wpcoDb, $Order, $Item;
$wpcoDb -> model = $Item -> model;
$items = $wpcoDb -> find_all(array('order_id' => $order -> id));
// You could use the render() method to output a template file in your extension plugin
//$this -> render('views' . DS . 'form', array('order' => $order, 'items' => $items), true, false, 'gateway');
// Alternatively, just output the HTML here
$merchantid = $this -> get_option('gateway_merchantid'); // the 'gateway_merchantid' you previously put in your settings
$mode = $this -> get_option('gateway_mode'); // the 'gateway_mode' you have in your settings
$amount = $order -> total;
$currency = $this -> get_option('currency');
$invoice = $order -> id;
$email = $order -> bill_email;
$tax = $order -> tax;
$discount = $order -> discount;
?>
<form action="<?php echo $action; ?>" method="post" id="gatewayform">
<input type="hidde" name="merchantid" value="<?php echo $merchantid; ?>" />
<input type="hidde" name="mode" value="<?php echo $mode; ?>" />
<input type="hidde" name="amount" value="<?php echo $amount; ?>" />
<input type="hidde" name="currency" value="<?php echo $currency; ?>" />
<input type="hidde" name="invoice" value="<?php echo $invoice; ?>" />
<input type="hidde" name="email" value="<?php echo $email; ?>" />
<input type="hidde" name="tax" value="<?php echo $tax; ?>" />
<input type="hidde" name="discount" value="<?php echo $discount; ?>" />
<p class="submit">
<input class="<?php echo $this -> pre; ?>button" type="button" name="back" value="<?php _e('&laquo; Back', $this -> plugin_name); ?>" onclick="history.go(-1);" />
<input class="<?php echo $this -> pre; ?>button" type="submit" name="continue" value="<?php _e('Continue &raquo;', $this -> plugin_name); ?>" />
</p>
</form>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#gatewayform').submit();
});
</script>
<?php
}
add_action('wpco_process_order_gateway', 'process_order', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment