Post by rhorne » Thu Jul 18, 2019 6:29 pm

We are using the MPN field in the products table to store a product denomination and I want to display this on the customer's invoice next to the quantity ordered.

I've edited the order_invoice.tpl file and was hoping I could just <?php echo $product['mpn']; ?> but it doesn't appear that the MPN is saved to the product array. What do I need to add what file in order to send the MPN value to the invoice?

Thanks

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by uksitebuilder » Thu Jul 18, 2019 7:18 pm

Unfortunately, MPN is not stored in the oc_order_product table

Therefore you would have to capture mpn at the point of the order being added to the database

Quite a bit of work involved and would most likely require a commercial support request via our commercial support forum

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by rhorne » Thu Jul 18, 2019 8:10 pm

Is there another field I could use as an alternative?

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by rhorne » Thu Jul 18, 2019 8:13 pm

I suppose I could just run a separate query against each line and manually look up the MPN from the oc_product table.

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by rhorne » Thu Jul 18, 2019 8:28 pm

I've done that and it works. Not the most elegant solution but it does the job and is less hassle than having to modify controller files.

If anyone else needs to do the same thing just add the following query under this line:

foreach ($order['product'] as $product) {

Code: Select all

$query = "SELECT mpn FROM oc_product WHERE model = '" . $product['model'] . "'";										
        $result = mysqli_query($dbh,$query);
        echo mysqli_error($dbh);
                
        while ($row = $result->fetch_assoc()) 
        {	
            $mpn = $row['mpn'];
        }
        mysqli_close($con);
          
Then you can echo mpn after the quantity.

Code: Select all

<td class="text-right"><?php echo $product['quantity'] . " " . $mpn; ?></td>
You will need to add your own database connection script to connect to the database. Unless someone can tell me how to user the current Opencart connection?

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by uksitebuilder » Fri Jul 19, 2019 2:54 pm

You could just create a new model function in the admin/model/sale/order.php file, then call that function in your controller.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom
Who is online

Users browsing this forum: No registered users and 46 guests