Post by wickedcaffeine » Thu Dec 31, 2020 2:48 am

Version : Opencart 3.0.3.6
Theme: https://themeforest.net/item/ravado-cof ... e/21347451

Hi All,
I am trying to modify the json response of "checkout/cart/add" to include the total price to update it live via ajax as a product gets added.

so far the json response is:

Code: Select all

{
"success":"Success: You have added <a href=\"https:\/\/mywebsite\/index.php?route=product\/product&amp;product_id=1487\">Wicked Coffee Diablo Blend 1kg<\/a> to your <a href=\"https:\/\/mywebsite\/index.php?route=checkout\/cart\">shopping cart<\/a>!",
"total":"1"
}
I have edited catalog/controller/checkout/cart.php and included the following on line 374 within the add method. I have also added this line to the remove method.

Code: Select all

$json['total_price'] = sprintf($this->language->get('total_price'), $this->currency->format($this->cart->getTotal(), $this->session->data['currency']));
However when calling checkout/cart/add I am still receiving the default response where as a am expecting "total_price":"R222" to be returned for example. I have cleared all caches and I am at a bit of a loss.

Any help would be greatly appreciated.


Posts

Joined
Sun Mar 03, 2019 3:00 am

Post by straightlight » Thu Dec 31, 2020 3:11 am


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sw!tch » Thu Dec 31, 2020 3:13 am

That theme already returns total_price in the JSON response. You added or modified that code?

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Who is online

Users browsing this forum: No registered users and 3 guests