Only show sub currency for PayPal ZAR {SOLVED}

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143222

-- 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: 11 years 1 month ago by GSW00d.

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

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #143268

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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143418

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.

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #143522

Hi,
My advice will be to change this line :

	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 :
	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 :
$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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143588

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.

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #143621

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 :
$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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143629

Thanks Mohamed!

Sorry for my confusing question. I'm wanting to turn the:

price_value_with_tax * 0.091133;
into:
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: 11 years 2 months ago by GSW00d.

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
11 years 2 months ago #143753

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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143785

Thanks Nicolas! How would we get the USD variable into Mohamed's code below?

Mohamed's Code:

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

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

Instead of:
* 0.091133

Last edit: 11 years 2 months ago by GSW00d.

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

  • Posts: 2334
  • Thank you received: 403
11 years 2 months ago #143855

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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #143866

I tried changing the 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:
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
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: 11 years 2 months ago by GSW00d.

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

  • Posts: 2334
  • Thank you received: 403
11 years 2 months ago #143909

You can use this 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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #144032

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: 11 years 2 months ago by GSW00d.

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

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #144096

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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #144656

Where should I place the below code?

$currencyUSDRate = $currencyUSD->currency_rate;
echo var_dump($currencyUSD)."<br>";
echo var_dump($currencyUSDRate)."<br>";

Last edit: 11 years 2 months ago by GSW00d.

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

  • Posts: 2334
  • Thank you received: 403
11 years 2 months ago #144797

Try

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.

  • Posts: 42
  • Thank you received: 2
11 years 2 months ago #144803

I put the code here

$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: 11 years 2 months ago by GSW00d.

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

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
11 years 2 months ago #144901

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.

  • Posts: 42
  • Thank you received: 2
11 years 1 month ago #147488

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:

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:
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
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: 11 years 1 month ago by GSW00d.

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

  • Posts: 26226
  • Thank you received: 4035
  • MODERATOR
11 years 1 month ago #147494

Hi,

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

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
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