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
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.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
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..
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....
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....
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
/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";
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
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";
Who is online
Users browsing this forum: No registered users and 2 guests