Post by asif » Thu Jan 31, 2008 10:34 pm

hi,
i want to get shipping cost alone... can anyone give me a code snippet how can i access it....
i m using thisi paypal.php page...but it givess error
$this->shipping->getCost($session->get('shipping_method'))
plz help

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by asif » Fri Feb 01, 2008 1:25 am

asif wrote: hi,
i want to get shipping cost alone... can anyone give me a code snippet how can i access it....
i m using thisi paypal.php page...but it givess error
$this->shipping->getCost($this->session->get('shipping_method'))
plz help
i solved this problem...i was makin a silly mistake in a hurry..."session" was accessible through $this as it is acting as local in Paymentpaypal class.
correct code is
$this->shipping->getCost($this->session->get('shipping_method'))

i required cost of shipping as i wanted to show Shipping cost separatly on PayPal checkout pages on paypal server. It is done by adding "shipping" hidden form element in /catalog/extension/payment/PayPal.php. It is working fine.

Another problem that i m facing is "shipping address" is not shown correctly on Paypal checkout pages. it shows payapl account address but the shipping address may be changed as customer wanted to ship it somewhere else. i m sending all the HTML variables in Form to paypal including "state" and "night_phone_a" which r not present in original code. any one can help????
it was not workin even before these changes..

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by bruce » Fri Feb 01, 2008 6:30 am

Is the shipping address not shown correctly or not at all?

If not at all, the product(s) on the cart may not be defined to require shipping. In that case, the cart does not prompt for a shipping address.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by asif » Fri Feb 01, 2008 2:37 pm

it shows customer's paypal account address on the "Pay Now" and "Return to Murcahnt" pages when i don't add "state" as a form variable while sending it to Paypal's site.
If i add "state" variable in the form, it doesn't show any address on "Pay Now" page but shows customer's paypal account address on "Return to Mercahnt" page with the heading "Shipped To".
It is confusing as the actual shipping address is somethin else. Mail and admin records are showing correct shipping address as they hav nothin to do with paypal.
I m also sending shipping amount in variable "Shipping" and it is showing it correctly and total amount is displayed with label "Total with shipping" on paypal page. So the cart is defined as shipping is required.

solution could be that it doesnt show any address on paypal pages or show correct address on all pages. The first one will also work for me if anyone can help in this regard....

New member

Posts

Joined
Wed Jan 16, 2008 10:35 pm

Post by drewxhawaii » Thu Mar 20, 2008 5:57 pm

i just implemented the same functionality. here is my code, tell me what you think. i didn't know how to get the subtotal, so i just used ((total) - (shipping)) for the "amount" field

/catalog/extension/payment/paypal.php

Code: Select all

		//$ouput .= '<input type="hidden" name="amount" value="' . $this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) . '" />' . "\n";
		$ouput .= '<input type="hidden" name="amount" value="' . ($this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) - $this->shipping->getCost($this->session->get('shipping_method'))) . '" />' . "\n";
		$ouput .= '<input type="hidden" name="shipping" value="' . $this->shipping->getCost($this->session->get('shipping_method')) . '" />' . "\n";

http://www.yourwebmasters.com


Newbie

Posts

Joined
Thu Mar 20, 2008 5:54 pm
Location - Honolulu, HI

Post by drewxhawaii » Thu Mar 20, 2008 6:33 pm

UPDATE

the way my shipping was calculated, i started getting amounts with more than 2 decimal places which caused paypal to error. here is my new code that fixes it:

/catalog/extension/payment/paypal.php

Code: Select all

//$ouput .= '<input type="hidden" name="amount" value="' . $this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) . '" />' . "\n";
$ouput .= '<input type="hidden" name="amount" value="' . number_format(($this->currency->format($this->order->get('total'), $currency, FALSE, FALSE) - $this->shipping->getCost($this->session->get('shipping_method'))), 2) . '" />' . "\n";
$ouput .= '<input type="hidden" name="shipping" value="' . number_format($this->shipping->getCost($this->session->get('shipping_method')), 2) . '" />' . "\n";

http://www.yourwebmasters.com


Newbie

Posts

Joined
Thu Mar 20, 2008 5:54 pm
Location - Honolulu, HI
Who is online

Users browsing this forum: No registered users and 2 guests