Answer the question
In order to leave comments, you need to log in
How to add your code to a page in Opencart?
I have a code that should be executed on the page "index.php?route=checkout/success" here it is:
foreach ($data['products'] as $product) {
$viberText = "";
$bitrix24products = "";
$prodId = $product['product_id'];
$order_mpn = $this->db->query("SELECT `mpn` FROM `" . DB_PREFIX . "product` WHERE `product_id` = '$prodId'");
$order_mpn = $order_mpn->row["mpn"];
$bitrix24option = empty($product['option']) ? "" : "<br/><br/><b>Опции:</b>";
$viberTextOption = empty($product['option']) ? "" : "Опции: \n";
$bitrix24products .=
"<b>Название:</b> ".$product['name']." (<a target='_blank' href='http://".$_SERVER['HTTP_HOST']."/index.php?route=product/product&product_id=".$product['product_id']."'>Ссылка</a>)".
"<br/><b>Количество:</b> ".$product['quantity']." шт.".
"<br/><b>Цена:</b> ".$product['price']." грн.".
"<br/><b>Сумма:</b> ".$product['total']." грн.".
"<br/><b>Поставщик:</b> ".$order_mpn.
$bitrix24option;
$viberText .="\nНазвание:\n".$product['name'].
"\nКоличество:".$product['quantity']." шт.".
"\nЦена: ".$product['price']." грн.".
"\nСумма: ".$product['total']." грн.".$viberTextOption;
foreach ($product['option'] as $option) {
if ($option['type'] == 'checkbox') {
$bitrix24products .= "<br/>-- Выбрано: ".$option['name'];
$viberText .= "\nВыбрано: ".$option['name'];
} else {
$bitrix24products .= "<br/>-- ".$option['name'].": ".$option['value'];
$viberText .= "\n".$option['name'].": ".$option['value'];
}
}
if ($product != end($data['products'])) {
$bitrix24products .= "<br/><br/>------------------------------------------------<br/><br/>";
$viberText .= "\n";
} else {
$bitrix24products .= "<br/>";
$viberText .= "\n";
}
$stack[$order_mpn] .= $viberText;
$stackBitrix[$order_mpn] .= $bitrix24products;
}
Answer the question
In order to leave comments, you need to log in
It’s hard to say a fragmentary piece of code, and I’ve had business with opencart for a long time, but the error is quite typical for opencart and it occurs with all users.
the bottom line is that there is no 'products' key in the $data array, most likely you either did not transfer everything, or vice versa, you overdid it too much, trace the variable in the old version and the new one.
Alternatively, the products may have previously been taken from the cart when it was available at the stage (checkout / checkout) and now it may be necessary to take from the order tables (checkout / success)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question