I have OC 3.0.3.8, custom theme.
I want to show a custom message on checkout page something like this: Approximate order weight: 0.5 kg
I am selling Resistors, Capacitors and other elements like these.
Because they are extremely lightweight ,sometimes their weight is under 1 gram, the default weight class is "gram" and I want to keep it that way.
In the controller file I inserted:
$data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
The output on checkout is for example "10g".
I want to show total weight in "kg" with 3 digits after decimal point - so the above example have to become 0.010kg.
How can I achieve this?
As you want 3 decimal places it probably easiest to do this. Otherwise you would need to make changes to the weight class.
Code: Select all
$data['weight'] = number_format($this->cart->getWeight() / 1000, 3, $this->language->get('decimal_point'), $this->language->get('thousand_point')) . 'kg';
Thanks man. Your decision works like a charm.ADD Creative wrote: ↑Sun Feb 05, 2023 1:17 amAs you want 3 decimal places it probably easiest to do this. Otherwise you would need to make changes to the weight class.
Code: Select all
$data['weight'] = number_format($this->cart->getWeight() / 1000, 3, $this->language->get('decimal_point'), $this->language->get('thousand_point')) . 'kg';
I have one more question.
On checkout page, there is an option for customers to increase or decrease quantity in cart by pressing Up or Down arrows or input new quantity in the input field.
Is it possible the total weight of the cart to be dynamically changed, when the arrows are pressed or new quantity is inserted.
Which file usually is responsible for updating the cart - checkout.twig file or .js file?
Attachments
Capture.JPG (10.33 KiB) Viewed 524 times
Who is online
Users browsing this forum: NicNie and 224 guests