Skip to content

Commit

Permalink
Merge pull request #4 from MichaelRotaru/master
Browse files Browse the repository at this point in the history
Display warning in module panel if currencies decimals "Display" option is set to "False"
  • Loading branch information
cosminbosutar authored Mar 31, 2021
2 parents 5e6d342 + 42e2e1e commit cf660e8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ Under the extension settings, you can:
* Set payment mode (test/live)
* Change the capture type (Instant/Manual via Paylike Tool)


## Limitations

* In order to use the Paylike module you'll need to set "Number of decimals" option to match the paylike supported decimals. Since this is a global setting that affects all currencies you cannot use at the same time currencies with different decimals.
Change this option from: Admin -> Preferences -> General

* Paylike doesn't provide support for customizable decimals display. In order to display the correct values durring the payment process you'll need to set "Decimals" option to value "True" for the "Edit" panel of the currencies used in your store.
Change this option from: Admin -> Localization -> Currencies
13 changes: 10 additions & 3 deletions paylikepayment/paylikepayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public function getContent() {
public function renderCurrencyWarning() {
$currencies = Currency::getCurrencies();
$warning_currencies = array();
$warning_decimals = array();
foreach ( $currencies as $currency ) {
if ( $this->getPaylikeCurrencyMultiplier( $currency['iso_code'] ) == 1 && Configuration::get( 'PS_PRICE_DISPLAY_PRECISION' ) != 0 ) {
$warning_currencies[0][] = $currency['iso_code'];
Expand All @@ -280,14 +281,20 @@ public function renderCurrencyWarning() {
$warning_currencies[3][] = $currency['iso_code'];
} elseif ( $this->getPaylikeCurrencyMultiplier( $currency['iso_code'] ) == 10000 && Configuration::get( 'PS_PRICE_DISPLAY_PRECISION' ) != 4 ) {
$warning_currencies[4][] = $currency['iso_code'];
}

if ( !$currency['decimals'] ) {
$warning_decimals[] = $currency['iso_code'];
}
}
if ( count( $warning_currencies ) ) {

if ( count( $warning_currencies ) || count( $warning_decimals ) ) {
$this->context->smarty->assign(
array(
'warning_currencies_decimal' => $warning_currencies,
'PS_PRICE_DISPLAY_PRECISION' => Configuration::get( 'PS_PRICE_DISPLAY_PRECISION' ),
'preferences_url' => $this->context->link->getAdminLink( 'AdminPreferences' )
'warning_currencies_display_decimals' => $warning_decimals,
'preferences_url' => $this->context->link->getAdminLink( 'AdminPreferences' ),
'currencies_url' => $this->context->link->getAdminLink( 'AdminCurrencies' )
)
);

Expand Down
38 changes: 28 additions & 10 deletions paylikepayment/views/templates/admin/currency-warning.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,32 @@
* @link http://www.derikon.com/
*
*}
<p class="alert alert-danger">
{l s='Note: Due to prestashop standards we need to abide to, currencies decimals must match the paylike supported decimals. In order to use the Paylike module for the following currencies, you\'ll need to set "Number of decimals" option to the number shown bellow from tab. Since this is a global setting that affects all currencies you cannot use at the same time currencies with different decimals.' mod='paylikepayment'}
<a href="{$preferences_url}">{l s='Preferences -> General' mod='paylikepayment'}</a>
<br>
{foreach from=$warning_currencies_decimal key=decimals item=currency}
{foreach from=$currency item=iso_code}
<b>{$iso_code} {l s='supports only' mod='paylikepayment'} {$decimals} {l s='decimals' mod='paylikepayment'}</b>
<br/>
{if $warning_currencies_decimal|@count}
<p class="alert alert-danger">
{l s='Note: Due to prestashop standards we need to abide to, currencies decimals must match the paylike supported decimals. In order to use the Paylike module for the following currencies, you\'ll need to set "Number of decimals" option to the number shown bellow from tab. Since this is a global setting that affects all currencies you cannot use at the same time currencies with different decimals.' mod='paylikepayment'}
<br/>
<a href="{$preferences_url}">{l s='Preferences -> General' mod='paylikepayment'}</a>
<br>
{foreach from=$warning_currencies_decimal key=decimals item=currency}
{foreach from=$currency item=iso_code}
<b>{$iso_code} {l s='supports only' mod='paylikepayment'} {$decimals} {l s='decimals' mod='paylikepayment'}</b>
<br/>
{/foreach}
{/foreach}
{/foreach}
</p>
</p>
{/if}

{if $warning_currencies_display_decimals|@count}
<p class="alert alert-warning">
{l s='Warning: Paylike doesn`t provide support for customizable decimals display. In order to display the correct values durring the payment process you`ll need to set "Decimals" option to value "True" for the edit menu of the currencies listed below.' mod='paylikepayment'}
<br/>
<a href="{$currencies_url}">{l s='Localization -> Currencies' mod='paylikepayment'}</a>
<br>
{foreach from=$warning_currencies_decimal key=decimals item=currency}
{foreach from=$currency item=iso_code}
<b>{$iso_code}</b>
<br/>
{/foreach}
{/foreach}
</p>
{/if}

0 comments on commit cf660e8

Please sign in to comment.