Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payment type - specific to item....


theMusicMan

Recommended Posts

Posted

Hi All

 

Is there a way to enforce a particular payment type for a specific product item...?

 

i.e. i am soon going to be offering 'downloadable' products on my site and don't want to allow customers to pay for these items by cheque - I only want a payment type of PayPal for these items i.e. Using this payment method for these items, I will receive payment from the customer before the download link is presented to the customer. It seems to me (unless I'm missing something here !!) that osC is not so strong in this area :? . With downloadable items, if a customer pays by cheque, the link is still presented to them immediately after they confirm the order - so they could potentially download the item and then decide not to send the cheque after all :shock: . I want to eliminate this possibility but cannot find a way to do it as a standard feature within osC.

 

So, is there a way to have a specific payment type for a specific product. I wish to continue to allow other goods to be paid for via cheque - but not for downloadable items...

 

Any help/advice please...

John

Posted

Hi,

 

Back up before you try!!!!

 

Open catalog/includes/class/order.php around line 133 AFTER this line;

 

    function cart() {

 

ADD this line

 

   $this->allowpay = true;

 

Then around line 225 AFTER this block of code;

 

      for ($i=0, $n=sizeof($products); $i<$n; $i++) {

       $this->products[$index] = array('qty' => $products[$i]['quantity'],

                                       'name' => $products[$i]['name'],

                                       'model' => $products[$i]['model'],

         'description' => $products[$i]['description'],

                                       'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $shipping_address['entry_country_id'], $shipping_address['entry_zone_id']),

                                       'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $shipping_address['entry_country_id'], $shipping_address['entry_zone_id']),

                                       'price' => $products[$i]['price'],

                                       'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

                                       'weight' => $products[$i]['weight'],

                                       'id' => $products[$i]['id']);

 

ADD these lines

 

  if (($products[$i]['id'] == 50) || ($products[$i]['id'] == 100)) {

   $this->allowpay = false;

 } else {

   $this->allowpay = true;

 }

 

 

The 50 and the 100 in the above code represent actual product_ids of the products you dont want the money order payment to appear for. In your example these are the id's of the downloadable products you can have one product eg produc_id 50 and that IF line will look like;

 

  if (($products[$i]['id'] == 50) || ($products[$i]['id'] == 100)) {

 

...or you can have any number of products by adding extra product ids in (where X is the product id) eg.

 

|| ($products[$i]['id'] == X)

 

Thats it for the order.php file.

 

 

 

 

Open your catalog/includes/modules/payment/moneyorder.php file

 

and REPLACE this code

 

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_MONEYORDER_ZONE > 0) ) {

       $check_flag = false;

       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_MONEYORDER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

       while ($check = tep_db_fetch_array($check_query)) {

         if ($check['zone_id'] < 1) {

           $check_flag = true;

           break;

         } elseif ($check['zone_id'] == $order->billing['zone_id']) {

           $check_flag = true;

           break;

         }

       }



       if ($check_flag == false) {

         $this->enabled = false;

       }

     }

   }

 

WITH this code.......

 

      if ($order->allowpay == true) {

  

  if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_MONEYORDER_ZONE > 0) ) {

       $check_flag = false;

       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_MONEYORDER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");

       while ($check = tep_db_fetch_array($check_query)) {

         if ($check['zone_id'] < 1) {

           $check_flag = true;

           break;

         } elseif ($check['zone_id'] == $order->billing['zone_id']) {

           $check_flag = true;

           break;

         }

       }



       if ($check_flag == false) {

         $this->enabled = false;

       }

     }

  

  } else {

    $this->enabled = false;

  }

  

   }

 

 

 

(Basically an IF and ELSE statement wrapped around)

 

Then upload the two files!!!!

 

A little crude on the product_id declarations but effective to your requirements! Any problems let me know, also let me know if this works for you!!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Posted

Hey Rumble....

 

I will certainly try this... allbeit a little apprehensively as I'm no coder or programmer... :? and of course I will let you know how I get on. It might take me a while, but I'll give it a go!

 

Can I also say that I really am very grateful to you for your help and support - not only have you told me (and others who might be interested) how this could be done, but you have actually done it as well...

 

It's my guess Rumble that (1) you're a superb programmer/coder, (2) you enjoy helping people and (3) you're a true gentleman.... :) Thankyou.

 

John

John

Archived

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

×
×
  • Create New...