When an order gets emailed, the sort order for product options are in a random order even though they have been set to a specific order in the product options section within the admin. I need the emailed order to have the same sort order as it shows on the website and checkout. How can this be done please?
Thanks
find all instances of:
Code: Select all
$order_options = $this->model_checkout_order->getOrderOptions($order_info['order_id'], $order_product['order_product_id']);
Code: Select all
$order_options = $this->model_checkout_order->getOrderOptions($order_info['order_id'], $order_product['order_product_id'], $order_product['product_id']);
replace:
Code: Select all
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
return $query->rows;
}
Code: Select all
public function getOrderOptions($order_id, $order_product_id, $product_id) {
$product_option_data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
foreach ($query->rows as $order_option) {
$order_product = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` WHERE `order_product_id` = '" . (int)$order_product_id . "' AND `order_id` = '" . (int)$order_id . "' AND `product_id` = '" . (int)$product_id . "'");
if ($order_product->num_rows) {
$product_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order");
foreach ($product_option_query->rows as $product_option) {
$product_option_value_data = array();
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order");
foreach ($product_option_value_query->rows as $product_option_value) {
$product_option_value_data[] = array(
'product_option_value_id' => $product_option_value['product_option_value_id'],
'option_value_id' => $product_option_value['option_value_id'],
'name' => $product_option_value['name'],
'image' => $product_option_value['image'],
'quantity' => $product_option_value['quantity'],
'subtract' => $product_option_value['subtract'],
'price' => $product_option_value['price'],
'price_prefix' => $product_option_value['price_prefix'],
'weight' => $product_option_value['weight'],
'weight_prefix' => $product_option_value['weight_prefix']
);
}
$product_option_data[] = array(
'product_option_id' => $product_option['product_option_id'],
'product_option_value' => $product_option_value_data,
'option_id' => $product_option['option_id'],
'name' => $product_option['name'],
'type' => $product_option['type'],
'value' => $product_option['value'],
'required' => $product_option['required']
);
}
}
return $product_option_data;
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
Any 2 Large Pizzas Only £17.99
- Add Topping(s) to 1st Pizza: BBQ Chicken
- Add Topping(s) to 1st Pizza: BBQ Chicken
- Add Topping(s) to 1st Pizza: BBQ Chicken
- Add Topping(s) to 2nd Pizza: Spicy Chicken
- First Pizza: Simply Classic
- First Pizza: Simply Classic
- Second Pizza: Simply Classic
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
viewtopic.php?f=131&t=155395&p=717698#p717698
In catalog/controller/mail/order.php file,
find all instances of:
Code: Select all
$data['products'][] = array(
Code: Select all
$sort_order = array();
foreach ($option_data as $key => $value) {
$sort_order[$key] = $value;
}
array_multisort($sort_order, SORT_ASC, $option_data);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
$data['products'][] = array(
I also cleared both cache before retrying a new order.
I also have the new piece of code in the above file that you gave me to replace.
Both locations must be used at all times when modifying either PHP and / or TWIG files.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
<b>Warning</b>: Missing argument 3 for ModelCheckoutOrder::getOrderOptions(), called in /home/account-name/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php on line 368 and defined in <b>/home/account-name/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php</b> on line <b>246</b><b>Notice</b>: Undefined variable: product_id in <b>/home/account-name/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php</b> on line <b>252</b>{"redirect":"https:\/\/website.com\/order-online\/index.php?route=checkout\/success"}
Clear your OC cache each times.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The email does come through but it freezes the checkout page. The invoice comes but it leaves the product option value blank, please see below. These are now in the right order though.SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
<b>Warning</b>: Missing argument 3 for ModelCheckoutOrder::getOrderOptions(), called in /home/account/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php on line 368 and defined in <b>/home/account/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php</b> on line <b>246</b><b>Notice</b>: Undefined variable: product_id in <b>/home/account/public_html/order-online/vqmod/vqcache/vq2-catalog_model_checkout_order.php</b> on line <b>252</b>{"redirect":"https:\/\/website.com\/order-online\/index.php?route=checkout\/success"}
Any 2 Medium Pizzas Only £15.99
- First Pizza:
- Add Topping(s) to 1st Pizza:
- Second Pizza:
- Add Topping(s) to 2nd Pizza:
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: AdsBot [Google], Gpli, Majestic-12 [Bot] and 14 guests