Help would be much appreciated... new to OpenCart, and still trying to figure out where everything is. Thanks!
This is from model->order.php
Code: Select all
$order_id = $this->db->getLastId();
/*--EDIT--*/
// Load Reward Points module
$this->load->model('module/points');
$this->points = $this->model_module_points;
/*--END EDIT--*/
foreach ($data['products'] as $product) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', name = '" . $this->db->escape($product['name']) . "', model = '" . $this->db->escape($product['model']) . "', price = '" . (float)$product['price'] . "', total = '" . (float)$product['total'] . "', tax = '" . (float)$product['tax'] . "', quantity = '" . (int)$product['quantity'] . "'");
$order_product_id = $this->db->getLastId();
foreach ($product['option'] as $option) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_option SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', product_option_value_id = '" . (int)$option['product_option_value_id'] . "', name = '" . $this->db->escape($option['name']) . "', `value` = '" . $this->db->escape($option['value']) . "', price = '" . (float)$product['price'] . "', prefix = '" . $this->db->escape($option['prefix']) . "'");
}
foreach ($product['download'] as $download) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_download SET order_id = '" . (int)$order_id . "', order_product_id = '" . (int)$order_product_id . "', name = '" . $this->db->escape($download['name']) . "', filename = '" . $this->db->escape($download['filename']) . "', mask = '" . $this->db->escape($download['mask']) . "', remaining = '" . (int)($download['remaining'] * $product['quantity']) . "'");
}
}
// Add reward points to customer account
if ($this->points->hasProductPoints($product['product_id'])) {
$this->points->addCustomerPoints($data['customer_id'], $this->points->getProductPoints($product['product_id']) * $product['quantity']);
}
Code: Select all
$this->data['products'] = array();
/*--EDIT--*/
$this->load->model('module/points');
$this->points = $this->model_module_points;
/*--END EDIT--*/
foreach ($this->cart->getProducts() as $product) {
$option_data = array();
foreach ($product['option'] as $option) {
$option_data[] = array(
'name' => $option['name'],
'value' => $option['value']
);
}
$this->data['products'][] = array(
'product_id' => $product['product_id'],
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
/*--EDIT--*/
'points' => $this->points->getProductPoints($product['product_id']),
/*--END EDIT--*/
'quantity' => $product['quantity'],
'tax' => $this->tax->getRate($product['tax_class_id']),
'price' => $this->currency->format($product['price']),
'total' => $this->currency->format($product['total']),
'href' => $this->url->http('product/product&product_id=' . $product['product_id'])
);