S
S
Sergey Miller2020-12-13 20:45:31
PHP
Sergey Miller, 2020-12-13 20:45:31

Opencart 3 how to add your price to the total cost when placing an order?

I mean controller/checkout/confirm.php

Here is the output of the final (total) cost of all goods at the last step "order confirmation":

$data['products'][] = array(
...
'total'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity'], $this->session->data['currency']),
...


I wrote my variable

if (isset($this->request->post['totalDeliveryPrice'])){
                if (!empty($this->request->post['totalDeliveryPrice'])) {
                $totalDeliveryPrice = $this->request->post['totalDeliveryPrice'];
                }
                else{
                $totalDeliveryPrice = 0;
                }
                } else{
                $totalDeliveryPrice = 0;
                }


How correctly to add it to total so that at the end of all mat functions stupidly plus the value from my variable?

As a result, something like - total = total + totalDeliveryPrice;

Tried like this, but not correctly (does not add its own price):
'total'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity'], $this->session->data['currency'], $totalDeliveryPrice),

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question