Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$globals[$this->selected_module]->process_button();


Guest

Recommended Posts

in includes/classes/payment.php I've been looking at this section of code:

	function process_button() {
  if (is_array($this->modules)) {
	if (is_object($GLOBALS[$this->selected_module]) && ($GLOBALS[$this->selected_module]->enabled) ) {
	  return $GLOBALS[$this->selected_module]->process_button();
	}
  }
}

Where is it set what $GLOBALS[$this->selected_module]->process_button(); actually is? I really need to be able to change this.

 

Thanks.

Link to comment
Share on other sites

Where is it set what $GLOBALS[$this->selected_module]->process_button(); actually is? I really need to be able to change this.

Change it to what? This call returns the selected payment's module form contents. And each payment module should include that member function.

Link to comment
Share on other sites

okay.. lets say I wanted to change what happens when you click on the process button for a paypal payment.

Would I change the code in includes/modules/payment/paypal.php?

I presume it would be the

	function process_button() {
  global $order, $currencies, $currency;

  if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
	$my_currency = $currency;
  } else {
	$my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
  }
  if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {
	$my_currency = 'GBP';
  }
  $process_button_string = tep_draw_hidden_field('cmd', '_xclick') .
						   tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .
						   tep_draw_hidden_field('item_name', STORE_NAME) .
						   tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
						   tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
						   tep_draw_hidden_field('currency_code', $my_currency) .
						   tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .
						   tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

  return $process_button_string;
}

I need to alter to change how the button works?

Link to comment
Share on other sites

The process_button function all it does it returns back the form content specific to paypal. The button for the form is processed by the checkout_confirmation.php. (Basically it just submits the form) by default

 

So if you need to change the behavior only when it's for paypal you could use the "title" or "code" variables because these are common for each payment module and you can access them from the checkout_confirmation.php

 

 if (isset($$payment->code) && $$payment->code =='paypal')) {
//do something paypal specfic
}

Link to comment
Share on other sites

Thanks,

I've used this code:

if($order->info['payment_method'] == 'PayPal'){
//do something paypal specfic
}

 

would your code be more suitable?

Link to comment
Share on other sites

Thanks,

I've used this code:

if($order->info['payment_method'] == 'PayPal'){
//do something paypal specfic
}

 

would your code be more suitable?

it's the same thing. just make sure the title of your paypal module is "PayPal" and not "paypal" case sensitivity matters.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...