Post by eWarrior » Wed Sep 21, 2016 10:43 am

I am hoping the community can help point me in the right direction.

I am building a vQmod for OC v1.5.5.1 to display the SKU at all points throughout the checkout and admin. I have nearly completed this but I have hit a brick wall on the admin sale order form (editing the order and adding products etc.).

Within the admin/view/template/sale/order_form.tpl file at line 1407 there is a reference to a product['model'] variable in the JavaScript section (full line below) but I can't seem to understand how this variable is set. Once I can work this out, I can proceed with the modification as I have set up the rest of the framework.

Line 1407:

Code: Select all

html += '  <td class="left">' + product['model'] + '<input type="hidden" name="order_product[' + product_row + '][model]" value="' + product['model'] + '" /></td>';
After this line, I have added:

Code: Select all

html += '  <td class="left">' + product['sku'] + '<input type="hidden" name="order_product[' + product_row + '][sku]" value="' + product['sku'] + '" /></td>';
However, whenever I add, modify or delete products, the SKU column is undefined.

Please note that a new sku column on the order_product table has been created. All rows have data and all the respective model files have been updated accordingly. Viewing the order works perfectly at all points so far (front end and admin) and the SKU displays as intended.

Saving a new product through the order editor results in the text "undefined" being saved to the new SKU column in the order_product table.

TL;DR

Can anyone help to explain how the JavaScript product['model'] variable is set in the admin/view/template/sale/order_form.tpl file (line 1407 for v1.5.5.1 or line 1107 for v2.3.0.2)?

Which pipleline should I follow to establish where to add in code to correctly set the product['sku'] variable?
Last edited by eWarrior on Wed Aug 08, 2018 11:13 pm, edited 6 times in total.

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by eWarrior » Thu Sep 22, 2016 6:53 am

Anyone? I must be missing something extremely obvious.

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by eWarrior » Wed Aug 08, 2018 11:03 pm

So I decided to revisit this as our inventory has continued to grow and we want to move forward with an improved inventory system. Yes, I realise it has been nearly 2 years and some are probably wondering why we don't just update to a newer OC version. The truth is that our store is heavily customised and the amount of work is quite daunting. Although, I am sure we will soon!

Anyway, back on topic.

My thoughts are that this data is being pulled through an AJAX request (I could be mistaken). This is the only thing that makes sense as I am adding new products that were not on the order_product table.

I can see this in admin/view/template/sale/order_form.tpl:

Code: Select all

source: function(request, response) {
        $.ajax({
            url: 'index.php?route=catalog/product/autocomplete&token=<?php echo $token; ?>&filter_name=' + encodeURIComponent(request.term),
            dataType: 'json',
            success: function(json) {   
                response($.map(json, function(item) {
                    return {
                        label: item.name,
                        value: item.product_id,
                        model: item.model,
                        option: item.option,
                        price: item.price
                    }
                }));
            }
        });
    },
I tried adding the line below but it didn't help.

Code: Select all

sku: item.sku,
I am obviously missing something here. Would anyone have a better understanding of this that can point me in the right direction?

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by straightlight » Thu Aug 09, 2018 12:16 am

Discussion found in 2 minutes using the search: http://forum.opencart.com/viewtopic.php ... 57#p228757

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by eWarrior » Thu Aug 09, 2018 9:11 am

straightlight wrote:
Thu Aug 09, 2018 12:16 am
Discussion found in 2 minutes using the search: http://forum.opencart.com/viewtopic.php ... 57#p228757
Straightlight, I mean no disrespect but clearly you did not read my post in its entirety. I am thankful though as I know your intention was to point me in the right direction.

I had no problem DISPLAYING the SKU at all desired points (product page, invoice, admin order etc.). I have also integrated the SKU into the checkout flow, compare and wish list functions etc. To clarify, the vQmod file I have created is 498 lines long. My only hurdle was with pulling in the SKU data through the AJAX request when using the order editor through the admin panel. For some reason I just couldn't see the solution.

I knew I must be missing something simple as I just could not work out which file was handling this request, but Jonathan was kind enough to point me in the right direction to the /catalog/controller/checkout/manual.php file.

After:

Code: Select all

$json['order_product'][] = array(
Add:

Code: Select all

'sku'        => ($product['sku'] ? $product['sku'] : 'P' . $product['product_id']),
Note: I added in the P + product_id variable as a global fallback for cases where the SKU has not been set.

I cannot recommend Jonathan (Clear Thinking) enough. I purchased his Ultimate Shipping and Shipping Estimate modules. His support has been outstanding.

http://www.getclearthinking.com/

New member

Posts

Joined
Wed Aug 29, 2012 4:27 pm

Post by straightlight » Thu Aug 09, 2018 8:05 pm

Topic is about an installed extension which the controller file has been addressed from the OP's second post rather than the first post. Information was provided as incomplete. Forum rules unfollowed.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 308 guests