Skip to main content

Only show sub currency for PayPal ZAR {SOLVED}

12 years 9 months ago - 12 years 8 months ago #143222 by GSW00d
-- url of the page with the problem -- : oikosfamily.co.za/index.php/store/checkout
-- Joomla version -- : 3.2.0
-- PHP version -- : 5.4.24
-- Browser(s) name and version -- : Safari 7.0.1

Hi!

We are a South African site wanting to use PayPal as our payment method. We know that ZAR is not supported, but we have had success setting primary currency as USD. Is it possible (via editing choice code) to display only the ZAR amount on the store and checkout? Currently we can get the products to display like this: $1.00 (R 0.50) etc
And we can get the checkout to display like this: $1.00

It it crucial that we display the store: R 0.50
and Checkout: R0.50

Even if the primary currency is set to USD in the backend.

We need to only display the ZAR value until the cart value is passed to the paypal page. Once directed to paypal, the $ price will be fine.

Many thanks,
Bruce Atkinson
Last edit: 12 years 8 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143268 by Mohamed Thelji
Hi,
The solution will probably be to
- Set the main currency of your shop to ZAR
- Edit the code of the file : "plugins\hikashoppayment\paypal\Paypal.php" so that you'll directly convert the price of your order to USD and send it to paypal.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143418 by GSW00d
Thanks Mohamed! That sounds exactly like the solution to our problem.

My PHP skills are still at the beginner level, I understand basic PHP syntax and logic from other programming languages.

Maybe if we could ask Nicolas or someone similar for a quick code fix? I'd imagine that we'd say ZAR * the current USD exchange rate variable (i.e. the variable containing a value like 0.986567 etc) or something like that?

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143522 by Mohamed Thelji
Hi,
My advice will be to change this line :
Code:
var $accepted_currencies = array( 'AUD','BRL','CAD','EUR','GBP','JPY','USD','NZD','CHF','HKD','SGD','SEK', 'DKK','PLN','NOK','HUF','CZK','MXN','MYR','PHP','TWD','THB','ILS','TRY' );
By :
Code:
var $accepted_currencies = array( 'ZAR','AUD','BRL','CAD','EUR','GBP','JPY','USD','NZD','CHF','HKD','SGD','SEK', 'DKK','PLN','NOK','HUF','CZK','MXN','MYR','PHP','TWD','THB','ILS','TRY' );

And you'll have to convert the total of your order by editing this line :
Code:
$vars['amount_1'] = round($order->cart->full_total->prices[0]->price_value_with_tax, (int)$this->currency->currency_locale['int_frac_digits']);
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143588 by GSW00d
Thank you Mohamed! That really helped and paypal is allowing ZAR. Unfortunately, It's still doing a 1->1 conversion as I'm at a loss about editing the lines pertaining to the $vars = round($order->cart->full_total->prices[0]->price_value_with_tax, (int)$this->currency->currency_locale);

As we have the Business edition of Hikashop, we are needing to use the auto-currency rates so we'd need to tie those variables into this fix somehow.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143621 by Mohamed Thelji
Hi,

As we have the Business edition of Hikashop, we are needing to use the auto-currency rates so we'd need to tie those variables into this fix somehow.

I didn't understood your question, but note that you'll only have to convert the ZAR total to USD like this for example :
Code:
$usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * 0.091133; $vars['amount_1'] = round($usd_total, 2);
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago - 12 years 9 months ago #143629 by GSW00d
Thanks Mohamed!

Sorry for my confusing question. I'm wanting to turn the:
Code:
price_value_with_tax * 0.091133;
into:
Code:
price_value_with_tax * USD Currency Rate Variable

So that the currency rate will be correct automatically. This was one of the features that caused us to buy Hikashop Business Edition.
Last edit: 12 years 9 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143753 by nicolas
The currency rate variable is $this->currency->currency_rate
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago - 12 years 9 months ago #143785 by GSW00d
Thanks Nicolas! How would we get the USD variable into Mohamed's code below?

Mohamed's Code:
Code:
$usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * 0.091133; $vars['amount_1'] = round($usd_total, 2);

The change:
Code:
* $this->USD->currency_rate

Instead of:
Code:
* 0.091133
Last edit: 12 years 9 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143855 by Eliot
What you suggest looks fine to me :).
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago - 12 years 9 months ago #143866 by GSW00d
I tried changing the code:
Code:
if(empty($this->payment_params->details)) { $usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * 0.091133; $vars['amount_1'] = round($usd_total, 2); $vars['item_name_1'] = JText::_('CART_PRODUCT_TOTAL_PRICE');

into:
Code:
if(empty($this->payment_params->details)) { $usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * $this->USD->currency_rate; $vars['amount_1'] = round($usd_total, 2); $vars['item_name_1'] = JText::_('CART_PRODUCT_TOTAL_PRICE');

But now the paypal payment plugin is returning a value of 0 to www.paypal.com/za/cgi-bin/webscr ?

And when I use the variable nicholas Provided
Code:
if(empty($this->payment_params->details)) { $usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * $this->currency->currency_rate; $vars['amount_1'] = round($usd_total, 2); $vars['item_name_1'] = JText::_('CART_PRODUCT_TOTAL_PRICE');

I return a value of 1 as it selects the primary ZAR currency. I'm sure my syntax and variable is wrong. Please help! :sick:
Last edit: 12 years 9 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #143909 by Eliot
You can use this code:
Code:
if(empty($this->payment_params->details)) { $currencyClass = hikashop_get('class.curreny'); $currencyUSD = $currencyClass->get('USD'); $usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * $currencyUSD->currency_rate; $vars['amount_1'] = round($usd_total, 2); $vars['item_name_1'] = JText::_('CART_PRODUCT_TOTAL_PRICE');

It should work. If it doesn't, replace 'USD' by the id of this currency.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 9 months ago - 12 years 9 months ago #144032 by GSW00d
Thanks Eliot, though I tried applying the code given and the page stays blank instead of going to www.paypal.com/cgi-bin/webscr .
Last edit: 12 years 9 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 9 months ago #144096 by Mohamed Thelji
The solution will only be to debug your new PayPal plugin by putting some trace by using the var_dump php function to see what you're sending to PayPal.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 8 months ago - 12 years 8 months ago #144656 by GSW00d
Where should I place the below code?
Code:
$currencyUSDRate = $currencyUSD->currency_rate; echo var_dump($currencyUSD)."<br>"; echo var_dump($currencyUSDRate)."<br>";
Last edit: 12 years 8 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 8 months ago #144797 by Eliot
Try
Code:
var_dump($currencyUSD);

No echo needed.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 8 months ago - 12 years 8 months ago #144803 by GSW00d
I put the code here
Code:
$currencyClass = hikashop_get('class.curreny'); $currencyUSD = $currencyClass->get('USD'); var_dump($currencyUSD);

And enabled debug mode in the PayPal plugin, but it's still returns a blank page. I'm still on Hikashop 2.2.2, would that affect anything?
Last edit: 12 years 8 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 8 months ago #144901 by nicolas
If the page stays blank, it means that you have an error in the code you added/modified.
Turn on the debug mode and error reporting options of the joomla configuration and try again and you should see the error message telling you what's wrong.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

12 years 8 months ago - 12 years 8 months ago #147488 by GSW00d
I have updated to Hikashop 2.3.0 and Joomla 3.2.3. I have also done what was suggested in the previous post.

Please find error messages below:
Code:
Warning: include_once(/home/oikosfam/public_html/administrator/components/com_hikashop/classes/curreny.php): failed to open stream: No such file or directory in /home/oikosfam/public_html/administrator/components/com_hikashop/helpers/helper.php on line 908 Warning: include_once(): Failed opening '/home/oikosfam/public_html/administrator/components/com_hikashop/classes/curreny.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/oikosfam/public_html/administrator/components/com_hikashop/helpers/helper.php on line 908 Fatal error: Call to a member function get() on a non-object in /home/oikosfam/public_html/plugins/hikashoppayment/paypal/paypal.php on line 127

The code I've edited:
Code:
class plgHikashoppaymentPaypal extends hikashopPaymentPlugin { var $accepted_currencies = array( 'ZAR','AUD','BRL','CAD','EUR','GBP','JPY','USD','NZD','CHF','HKD','SGD','SEK', 'DKK','PLN','NOK','HUF','CZK','MXN','MYR','PHP','TWD','THB','ILS','TRY' );

and
Code:
if(empty($this->payment_params->details)) { $currencyClass = hikashop_get('class.curreny'); $currencyUSD = $currencyClass->get('USD'); $usd_total = $order->cart->full_total->prices[0]->price_value_with_tax * $currencyUSD->currency_rate; $vars['amount_1'] = round($usd_total, 2); $vars['item_name_1'] = JText::_('CART_PRODUCT_TOTAL_PRICE');
Last edit: 12 years 8 months ago by GSW00d.

Please Log in or Create an account to join the conversation.

12 years 8 months ago #147494 by Jerome
Hi,

Currenc|/b]y, not "curreny".

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: GSW00d

Please Log in or Create an account to join the conversation.

Time to create page: 0.121 seconds
Powered by Kunena Forum