Magento 2 Currency symbol is not showing - magento2

I have 2 stores English and Arabic. Default Store is Arabic and default currency is SAR. Currency symbol is showing fine on English Store but not showing anywhere on Arabic store. It only showing price like this 44 on product listing page and on single product page.

I fixed it.
Posting my answer may be it can help someone.
edit this file.
vendor\magento\zendframework1\library\Zend\Locale\Data\ar_SA.xml
and remove following code.
<numbers>
<currencyFormats numberSystem="latn">
<currencyFormatLength>
<currencyFormat type="standard">
<pattern>¤#0.00</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
</numbers>
UPDATED ANSWER ========
I got better solution instead editing core file you can do it with observer.
Vendor/Module/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="currency_display_options_forming">
<observer name="change_currency_position" instance="Vendor\Module\Model\Observer\ChangeCurrencyPosition" />
</event>
</config>
and observer File.
use Magento\Framework\Event\ObserverInterface;
class ChangeCurrencyPosition implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$currencyOptions = $observer->getEvent()->getCurrencyOptions();
$currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);
return $this;
}
}
Need to change the 'position' to RIGHT.

Its a bug in 2.4.3:
src\vendor\magento\module-directory\Model\Currency.php
Comment out these lines:
if ($this->canUseNumberFormatter($options)) {
return $this->formatCurrency($price, $options);
}
Then:
php -dmemory_limit=6G bin/magento setup:upgrade
php -dmemory_limit=6G bin/magento setup:di:compile
php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
php -dmemory_limit=6G bin/magento cache:flush
Editing core is bad, we can create preference.

If #Ask4Tec's solution is not working
Try this
Copy the currency and numbers block from en.xml file and paste it into the ar_SA.xml file
Clean and flush cache
Check after hard refresh

Update ar_SA.xml like below:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ldml SYSTEM "../../common/dtd/ldml.dtd">
<!-- Copyright © 1991-2013 Unicode, Inc.
CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
For terms of use, see http://www.unicode.org/copyright.html
-->
<ldml>
<identity>
<version number="$Revision: 9287 $"/>
<generation date="$Date: 2013-08-28 21:32:04 -0500 (Wed, 28 Aug 2013) $"/>
<language type="ar"/>
<territory type="SA"/>
</identity>
<dates>
<calendars>
<calendar type="islamic">
<dateTimeFormats>
<availableFormats>
<dateFormatItem id="Md" draft="contributed">M/d</dateFormatItem>
<dateFormatItem id="MEd" draft="contributed">E, M/d</dateFormatItem>
<dateFormatItem id="MMMd" draft="contributed">MMM d</dateFormatItem>
<dateFormatItem id="MMMEd" draft="contributed">E, MMM d</dateFormatItem>
</availableFormats>
</dateTimeFormats>
</calendar>
</calendars>
</dates>
<numbers>
<symbols numberSystem="latn">
<decimal>.</decimal>
<group>,</group>
<list>;</list>
<percentSign>%</percentSign>
<plusSign>+</plusSign>
<minusSign>-</minusSign>
<exponential>E</exponential>
<superscriptingExponent>×</superscriptingExponent>
<perMille>‰</perMille>
<infinity>∞</infinity>
<nan>NaN</nan>
</symbols>
<decimalFormats numberSystem="latn">
<decimalFormatLength>
<decimalFormat>
<pattern>#,##0.###</pattern>
</decimalFormat>
</decimalFormatLength>
</decimalFormats>
<currencyFormats numberSystem="latn">
<currencyFormatLength>
<currencyFormat type="standard">
<pattern>¤#,##0.00</pattern>
</currencyFormat>
<currencyFormat type="accounting">
<pattern>¤#,##0.00;(¤#,##0.00)</pattern>
</currencyFormat>
</currencyFormatLength>
<unitPattern count="one">{0} {1}</unitPattern>
<unitPattern count="other">{0} {1}</unitPattern>
</currencyFormats>
<currencies>
<currency type="USD">
<displayName>US Dollar</displayName>
<displayName count="one">US dollar</displayName>
<displayName count="other">US dollars</displayName>
<symbol>$</symbol>
</currency>
</currencies>
</numbers>
</ldml>

Related

INVALID_REQUEST: Field [order.avsDetails.billToFirstname] was not in charset [ISO-8859-1]

For some Reasons when I use OnTap MasterCard Extension, Any Arabic characters in shippment addresses throws an error:
INVALID_REQUEST: Field [order.avsDetails.billToFirstname] was not in charset [ISO-8859-1]
The extension link :
https://marketplace.magento.com/ontap-module-mastercard.html
Please help.
You can try encoding the data generated in the Builders (inside the Gateway/Request folder) by using plugins.
You can read more how to create plugins here that perform the encoding on all the fields in the builders when needed.
You will create a new module that is doing the modifications needed on the extension you took from the market.
To define your builder in this case your di.xml will look something like:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="\OnTap\MasterCard\Gateway\Request\ShippingDataBuilder">
<plugin name="jsparo_ontap_mastercard_gateway_request_shippingdatabuilder" type="Jsparo\MasterCard\Plugin\Gateway\Request\ShippingDataBuilder" sortOrder="1"/>
</type>
</config>
And the Plugin/Gateway/Request/ShippingDataBuilder.php that you will be something like:
<?php
namespace Jsparo\MasterCard\Plugin\Gateway\Request;
class ShippingDataBuilder {
public function afterBuild(array $subject, $result) {
array_walk_recursive($result, function(&$value) {
$value = mb_convert_encoding($value, 'ISO-8859-1', 'UTF-8');
}
return $result;
}
}
You will have to do this for all the builders that generate incorrect data.

DocuSign API not asking or setting the dateSigned though it is present in the xml

Having followed the example found earlier here on StackOverflow (dateSignedTabs does not work), I still fail to get a signature date to appear. Here's a snippet of the xml.
<?xml version="1.0" encoding="UTF-8"?>
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
<emailSubject>Boiler Contract -00006)</emailSubject>
<status>sent</status>
<documents>
<document>
<documentId>1</documentId>
<name>VDBK SW6-CSIK-0001.pdf</name>
</document>
</documents>
<recipients>
<signers>
<signer>
<recipientId>1</recipientId>
<routingOrder>1</routingOrder>
<note>Team</note>
<email>joebloggs#gmail.com</email>
<name>Eric Test6-1</name>
<tabs>
<signHereTabs>
<signHere>
<xPosition>58</xPosition>
<yPosition>617</yPosition>
<documentId>1</documentId>
<pageNumber>1</pageNumber>
</signHere>
</signHereTabs>
<dateSignedTabs>
<dateSigned>
<xPosition>58</xPosition>
<yPosition>440</yPosition>
<tabLabel>Date Signed</tabLabel>
<name>Date Signed</name>
<documentId>1</documentId>
<pageNumber>1</pageNumber>
<recipientId>1</recipientId>
</dateSigned>
</dateSignedTabs>
</tabs>
</signer>
</signers>
</recipients>
</envelopeDefinition>
Can anybody spot why this is off?

Magento: Send a mail directly to my supplier when payment is set to be received

I'd like to send an automatic email to my supplier, when the order is checked as payed. I've a external supplier that start to produce when i tell him, so when the payment is received, I can confirm to him the production. I'd like to automate this process and I like to use a similar confirmation order email, but adding a custom attribute instead of the sku.
Thank you!
--- EDIT ---
I'm reached my goal inserting those lines, but I've still some problem in the Observer line 24 at $result line, there's an error for one ",".
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Notifyowner>
<version>0.1.0</version>
</Electricjesus_Notifyowner>
</modules>
<global>
<models>
<notifyowner>
<class>Electricjesus_Notifyowner_Model</class>
</notifyowner>
</models>
<events>
<sales_order_payment_pay>
<observers>
<notifyOwnerEvent>
<class>notifyowner/observer</class>
<method>notifyOwnerEvent</method>
</notifyOwnerEvent>
</observers>
</sales_order_payment_pay >
</events>
</global>
Electricjesus_Notifyowner.xml
<?xml version="1.0"?>
<config>
<modules>
<Electricjesus_Notifyowner>
<active>true</active>
<codePool>local</codePool>
</Electricjesus_Notifyowner >
</modules>
and Observer.php with the error
// parameters you can get from the $observer parameter:
// array(’payment’ ? $this, ‘invoice’ ? $invoice)
$payment = $observer->getPayment();
$invoice = $observer->getInvoice();
// derivative data
$order = $invoice->getOrder(); // Mage_Sales_Model_Order
$ownerEmail = 'test#gmail.com';
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('order_new');
$emailTemplate
->setSenderName(Mage::getStoreConfig('trans_email/ident_support/name'))
->setSenderEmail(Mage::getStoreConfig('trans_email/ident_support/email'))
->setTemplateSubject('Prova di Ordine Confermato dopo pagamento');
$result = $emailTemplate->send(Mage::getStoreConfig('trans_email/ident_general/email'),(Mage::getStoreConfig('trans_email/ident_general/name'), $observer->getCustomer()->getData());
/*
- build data
- build email structure
- send email via any php mailer method you want
*/
return $this; // always return $this.
}
}
Can you pls help me to undestand why the error for a comma? Thank you!
There in magento has two dispatch event
1.sales_order_payment_place_end
2. sales_order_payment_place_start.
As per your Please follow my below code. add observer
<global>
<events>
<sales_order_payment_place_end>
<observers>
<mymodule>
<type>singleton</type>
<class>mymodule/observer</class>
<method>handleOrder</method>
</mymodule>
</observers>
</sales_order_payment_place_end>
</events>
</global>
Then create observer.php under model directory
class Mycompany_Mymodule_Model_Observer
{
public function handlePayment($observer)
{
$order = $observer->getOrder();
$payment=$order->getPayment();
/// put logic as per your requirement.
}
}
I did not get time to test this code but i am sure logic is same like this. Thanks.

Magento getEvent()->getOrder empty

I'm trying to get an Observer working to see if a payment has been made via check/cheque, I know the Observer is being used as I have a log record to show. However when I try to access the Order it is either empty or will not print to the log file.
app/etc/modules/Foo_Bar.xml
<?xml version="1.0"?>
<config>
<modules>
<Foo_Bar>
<active>true</active>
<codePool>local</codePool>
</Foo_Bar>
</modules>
</config>
app/code/local/Foo/Bar/etc/config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<global>
<models>
<foo_bar>
<class>Foo_Bar_Model</class>
</foo_bar>
</models>
<events>
<sales_order_payment_place_end> <!-- event -->
<observers>
<foo_bar> <!-- unique for event -->
<!-- type: singleton | disable | model -->
<class>foo_bar/observer</class>
<method>SalesOrderPaymentPlaceEnd</method>
</foo_bar>
</observers>
</sales_order_payment_place_end>
</events>
</global>
</config>
app/code/local/Foo/Bar/Model/Observer.php
<?php
class Foo_Bar_Model_Observer
{
public function SalesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
{
Mage::log('Location: SalesOrderPaymentPlaceEnd');
$order = $observer->getEvent()->getOrder();
Mage::log('order: '.$order);
}
}
The first log works as expected, however I'm sure getOrder() isn't working as my second log entry just prints 'order: '.
Thanks
#James has already commented this..I am explaning
The event "sales_order_payment_place_end" located in "app\code\core\Mage\Sales\Model\Order\Payment.php" .
The event have only one parameter that is Payment. So
$order = $observer->getEvent()->getOrder();
will not work. You need to use
$orderPayment = $observer->getEvent()->getPayment();
What worked for me was below:
public function autoInvoiceForOfflinePayment(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getPayment()->getOrder();
// In my case I was trying to get the payment method code, e.g.
$order->getPayment()->getMethodInstance()->getCode()
}
I hope this helps (Magento EE 1.14.2)
What I discovered, which I forget and often discover again when creating a hook is to look at the line in the file dispatching the event:
e.g. "app\code\core\Mage\Sales\Model\Order\Payment.php"
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
So you want to get the event first, then in the array the payment variable:
$order = $observer->getEvent()->getPayment();
From there you can get any public functions in that file, the same principle seems to apply throughout.

Joomla 1.7: change meta tags from system plugin

Joomla version 1.7
Plugin enabled in admin part
Plugin code:
<?php
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgSystemMetatags extends JPlugin
{
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
}
public function onBeforeRender()
{
$document =& JFactory::getDocument();
$document->setMetaData('keywords', 'test keywords');
}
}
But this doesn't work
Meta description renders value, which set in global configuration
plugin xml file
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.7" type="plugin" group="system" method="upgrade" client="site">
<name>System - Metatags</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin#joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.7.0</version>
<description></description>
<files>
<filename plugin="metatags">metatags.php</filename>
<filename>index.html</filename>
</files>
</extension>
use onBeforeRender instead of onAfterRender.
When onAfterRender event is triggered the output of the application is already available in the response buffer.