cancel
Showing results for 
Search instead for 
Did you mean: 

magento 2 add span tag in price

magento 2 add span tag in price

I am facing an issue with Magento 2 checkout success page.
I have added API for SMS to receive the final SMS about the order and when SMS is received it's showing the "span" tag around the price like below
 
3 5111 SHJ
<span class="price">3 AED</span> pos
Balance: 0
 
my line of code is:
$textMsg[] = $formatPrice->currency($order->getGrandTotal()).' '." pos ". $order->getPayment()->getCcStatus();
3 REPLIES 3

Re: magento 2 add span tag in price

Hi,
You can use the observer "checkout_onepage_controller_success_action" and get grandtotal of the order.
this will not return you the html.

/**
 * Create an order in Companyname when order status match the statuses in the backend
 *
 * @param EventObserver $observer
 * @return void
 */
public function execute(EventObserver $observer){
   $order = $observer->getEvent()->getOrder();
   $shipping_method    = $order->getShippingMethod();
   $order_status       = $order->getStatus();
   $orderTotal = $order->getGrandTotal();
   if($order_status == 'processing'){
        // use your custtom api
    }
}

Re: magento 2 add span tag in price

Hello @AsifJalil ,

try by replacing that with below code :

$textMsg[] = strip_tags($formatPrice->currency($order->getGrandTotal())).' '." pos ". $order->getPayment()->getCcStatus();

Let me know if it works for you.

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !

Re: magento 2 add span tag in price