Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Want to display Ebay Fee on checkout confirmation


psleman

Recommended Posts

Here is the code:

class ot_paypal_fee {
    var $title, $output;

    function ot_paypal_fee() {
      $this->code = 'ot_paypal_fee';
      $this->title = MODULE_ORDER_TOTAL_PAYPAL_TITLE;
      $this->description = MODULE_ORDER_TOTAL_PAYPAL_DESCRIPTION;
      $this->enabled = ((MODULE_ORDER_TOTAL_PAYPAL_STATUS == 'true') ? true : false);
      $this->sort_order = MODULE_ORDER_TOTAL_PAYPAL_SORT_ORDER;
      $this->output = array();
    }

    function process() {
      global $order, $currencies, $paypal_fee;

      if (MODULE_ORDER_TOTAL_PAYPAL_STATUS == 'true') {
        //check if payment method is paypal. If yes, add fee.
        if ($GLOBALS['payment'] == 'paypal') {
        $paypal_fee = tep_round(((MODULE_ORDER_TOTAL_PAYPAL_FEE/100) * $order->info['total']), $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
            $order->info['total'] += $paypal_fee;
            $this->output[] = array('title' => $this->title . ' (' . MODULE_ORDER_TOTAL_PAYPAL_FEE . '%):',
                                    'text' => $currencies->format($paypal_fee, true,  $order->info['currency'], $order->info['currency_value']),
                                    'value' => $paypal_fee);
        } 
      }
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_PAYPAL_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }

      return $this->_check;
    }

    function keys() {
      return array('MODULE_ORDER_TOTAL_PAYPAL_STATUS', 'MODULE_ORDER_TOTAL_PAYPAL_SORT_ORDER', 'MODULE_ORDER_TOTAL_PAYPAL_FEE');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display PAYPAL FEE', 'MODULE_ORDER_TOTAL_PAYPAL_STATUS', 'true', 'Do you want this module to display?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_PAYPAL_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PAYPAL Fee (%)', 'MODULE_ORDER_TOTAL_PAYPAL_FEE', '1', 'Your PayPal fee in percent (%)', '6', '3', now())");
    }
    

    function remove() {
      $keys = '';
      $keys_array = $this->keys();
      $keys_size = sizeof($keys_array);
      for ($i=0; $i<$keys_size; $i++) {
        $keys .= "'" . $keys_array[$i] . "',";
      }
      $keys = substr($keys, 0, -1);

      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
    }
  }
?>
 

Link to comment
Share on other sites

Paul I assume you've installed it?  What is happening or not happening as the case might be.  At a glance your approach looks okay.  Are you able to output anything at all?

Dan

Link to comment
Share on other sites

Be careful there. If the purpose of this exercise is to charge extra for customers using PayPal (to cover the fee), you should carefully read their Terms of Service. I know they used to forbid charging extra; I don't know if they still do.

Link to comment
Share on other sites

12 hours ago, Dan Cole said:

Paul I assume you've installed it?  What is happening or not happening as the case might be.  At a glance your approach looks okay.  Are you able to output anything at all?

Dan

Yes I have uploaded the files. I am wondering if there is something else I need to do to another file to actually get it to display on the website.  Thank you very much for your assistance.  

Link to comment
Share on other sites

When you add a module you need to install it so that the configuration variables are added to the database configuration file....go to admin and click on the tabs indicated below....

.admin -> modules -> order total -> install tab -> select etc.

Dan

 

Link to comment
Share on other sites

18 minutes ago, Dan Cole said:

When you add a module you need to install it so that the configuration variables are added to the database configuration file....go to admin and click on the tabs indicated below....

.admin -> modules -> order total -> install tab -> select etc.

Dan

 

Yes I have installed the module.

Link to comment
Share on other sites

Okay....so can I assume that you're not seeing anything when you visit your checkout confirmation page?   Did you try adding an echo or print_R statement after your globals to see if it's being loaded?  If that works you can then test your if statements to see what is or isn't working the way you intend.

Dan

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...