Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payments to Manufacturers


Guest

Recommended Posts

Hi there,

 

I am trying ot set up a system where payment is forwarded to the manufacturer of the product. I am using the Paypal IPN module and I want it to select the paypal email address depending on Manufacturer_id

 

Here's an example of what i'm trying to do to with checkout_paypalipn.php:

 

if ($HTTP_GET_VARS['manufacturers_id'] == '10') {

tep_redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&[email protected](blah,blah)

}else{

 tep_redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&business=".MODULE_PAYMENT_PAYPALIPN_ID.(blah,blah)

}

I'm not much of a programmer, but anyone who is should be able to get an Idea for what I'm trying to do here - I just can't seem to call the "manufacturers_id" variable, I'm guessing I'll have to hit the database... I managed to get it to show up in product_info.php but I just can't call it in checkout_paypalipn.php :(

 

Any help you can give me is very much appreciated :)

 

Kindest regards

Lobos

Link to comment
Share on other sites

Unless you added code to pass it to checkout_payment.php, the paypalipn file won't know anything about manufacturers_id. You would have to look it up from the products_id (which will be stored in the products array in the $cart) or add it to the cart information.

 

Hth,

Matt

 

P.S. Have you considered what would be necessary to handle the case of products from multiple manufacturers in the same order? Something to keep in mind before going live.

Link to comment
Share on other sites

Thanks for the reply,

 

I was just outside having a smoke thinking about it and yes I then realised it would not be possible because if a buyer had items in their cart from different manufacturers.

 

Oh well, back to the drawing board... Unless I make it so only one item can be purchased at a time - would this be possible?

 

Kindest regards

Lobos

Link to comment
Share on other sites

You could make it so that it would charge each manufacturer in turn. However, the code for that might get a bit thorny. If you do single items, you might as well go back to the original PayPal buy now buttons--that's how they work anyway.

 

Good luck,

Matt

Link to comment
Share on other sites

If you do single items, you might as well go back to the original PayPal buy now buttons--that's how they work anyway.

Hi there,

 

I'm not worried about the single purchase, I got into this for the IPN and secure downloads.

 

Is there any possiblity of you being more specific as how you would get the manufacturer_id into the checkout file?

 

I would appreciate this very much!

 

Kindest regards

Lobos

Link to comment
Share on other sites

Change this line around 273 of includes/classes/shopping_cart.php:

        $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

to something like

        $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.manufacturers_id");

Add to the following section around lines 284-93:

          $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

as follows

                                    'tax_class_id' => $products['products_tax_class_id'],
                                   'manufacturers_id' => $products['manufacturers_id'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

Then you can access the products from $cart->get_products and you will have the manufacturers_id for each product, e.g.

$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
 //do whatever based on $products[$i]['manufacturers_id']
}

Hth,

Matt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...