Post by CEMinistries » Wed Oct 07, 2015 11:25 pm

We use a 2.0.3.1 install of OC to keep track of subscriptions only (Recurring Module does not have the ability to edit and change orders so it's not going to work). However, when we change the product prices they need to push to past orders so that the orders will be constantly updating for current susbcriptions.

I am basing this off of Qphoria's push download module: http://forum.opencart.com/viewtopic.php?t=10185

The following code is located in model/catalog/product.php under the editProduct function

Code: Select all

$product_qry = $this->db->query("SELECT price from " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
		$new_price = $product_qry->row['price'];
		$order_qry = $this->db->query("SELECT quantity from " . DB_PREFIX . "order_product WHERE order_product_id = '" . $order_product_id . "'");
		$product_quantity = $order_qry->row['quantity'];
		$new_total = $product_quantity * $new_price;
		$this->db->query("UPDATE " . DB_PREFIX . "order_product SET price = '" . $new_price . "' WHERE product_id = '" . (int)$product_id ."'");
		$this->db->query("UPDATE " . DB_PREFIX . "order_product SET total = '" . $new_total . "' WHERE order_product_id = '" . (int)$order_product_id . "'");
Updating the product price is working wonderfully. However, After implementing updating the product total I receive the error: Notice: Undefined variable: order_product_id in ../model/catalog/product.php

Where and how would I define this variable?

New member

Posts

Joined
Wed Apr 16, 2014 11:17 pm

Post by CEMinistries » Thu Oct 08, 2015 10:58 pm

Updated my code and no longer receiving any errors; however it's not updating the total in the order_product database.

Code: Select all

 $product_qry = $this->db->query("SELECT price FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
    $new_price = $product_qry->row['price'];

    $order_product_id_qry = $this->db->query("SELECT order_product_id FROM " . DB_PREFIX . "order_product");
    $order_product_id = $order_product_id_qry->row['order_product_id'];

    $order_qry = $this->db->query("SELECT quantity FROM " . DB_PREFIX . "order_product WHERE order_product_id = '" . (int)$order_product_id . "'");
    $product_quantity = $order_qry->row['quantity'];

    $new_total = $product_quantity * $new_price;

    $this->db->query("UPDATE " . DB_PREFIX . "order_product SET price = '" . $new_price . "' WHERE product_id = '" . (int)$product_id ."'");
    $this->db->query("UPDATE " . DB_PREFIX . "order_product SET total = '" . $new_total . "' WHERE order_product_id = '" . (int)$order_product_id . "'");

New member

Posts

Joined
Wed Apr 16, 2014 11:17 pm
Who is online

Users browsing this forum: No registered users and 2 guests