Post by support_cs » Tue Apr 24, 2018 3:10 am

Running OC 2.3.0.2 with Journal 2.9.5. In admin/view/template/sale/order_form.tpl, a list is created (and displayed) of the products in an existing order:

Code: Select all

                    <?php if ($order_products || $order_vouchers) { ?>
                    <?php $product_row = 0; ?>
                    <?php foreach ($order_products as $order_product) { ?>
The thing is, I can't find where $order_products is defined, ANYWHERE in the source code. And a problem arises when you actually go to edit an order, and you click over to the 2nd tab, for Products, and you very briefly see the table of order products as created by the code above, but it is quickly replaced by the code created via ajax/JSON later on in order_form.tpl:

Code: Select all

// Add all products to the cart using the api
$('#button-refresh').on('click', function() {
Because that JSON function relies on function getProducts(), a function that fetches product data based only on product_id, it combines multiple differently-optioned products into a single one. For instance, if you sell shirts that come in red and blue, and a customer had ordered one in each color, the edit order screen would quickly show "Shirt - Red - Qty 1" and "Shirt - Blue - Qty 1" but then the JSON/ajax call would combine those two items, and just show that the order has Shirt - Qty 2.

So I guess my question is twofold: One, where and how does $order_products get defined? And two, why does this JSON/ajax code for the order edit screen ignore the unique product data found in the oc_order_product table and instead just pull only the product info based on the product_id?

Newbie

Posts

Joined
Tue Apr 24, 2018 2:48 am

Post by OSWorX » Wed Apr 25, 2018 1:25 pm

You are asking questions nobody else then the theme developer can answer.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by support_cs » Wed Apr 25, 2018 9:13 pm

I apologize; I assumed it wasn't necessarily theme-specific since it has to do with basic backend order processing.

Newbie

Posts

Joined
Tue Apr 24, 2018 2:48 am

Post by Johnathan » Wed Apr 25, 2018 10:38 pm

Most themes don't modify the admin panel, and that code is in the default order_form.tpl file, so I don't think this is a Journal issue.

The order editor in OpenCart is complex, because it uses the API to call front-end functions to get the order information, and rebuild the order as you edit it. It can be hard to follow all the paths, because it's not the usual "look in the controller file" process. You may need to hire an expert if you can't figure out the process and get the bug fixed (or can't find a fix for it in the forums).

For your questions, here is some clarification:

1. All variables are defined in the related controller file. In this case, that would be /admin/controller/sale/order.php. You'd look for $data['order_products']

2. The products with different options getting combined would be a bug in my estimation. I don't know if this occurs in a default 2.3 installation, but if it does, you should look in that bug topic to see if there's a fix for this. I would think someone would have reported it if it's a bug in the default version. If you want to try fixing it yourself, you'd probably need to look at the front-end getProducts() function. Based on the ajax code that calls it, the file path should be this: /catalog/controller/api/cart.php

If you can't find a fix, I do have an Edit Order Line Items extension that can edit orders in a process completely separate from the built-in order editor. It won't have the issue of combining products with the same product_id, because it uses an independent process to get the order information and edit the order (not using the OpenCart API).

Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 35 guests