AbanteCart Community
Shopping Cart Operations => Support => General Support => Topic started by: ygalbrami on June 01, 2013, 11:18:27 AM
-
is there any way so i can see the sku next to product name?
i need this when buyer checkout in page: index.php?rt=checkout/confirm
i try a lot of option but i can make this happend,
please help me.
-
You need to change template to display the SKU and possibly you will need to add it in the controller to be passed to the view.
-
Can you please give me code to add or change? I want the code will be a code of a ante cart I don't want to use my code
Thanks
-
open file core/lib/cart.php... go to line 247 and add sku into array
$result = array(
'product_id' => $product_query['product_id'],
'name' => $product_query['name'],
'model' => $product_query['model'],
'shipping' => $product_query['shipping'],
'option' => $option_data,
'download' => $download_data,
'quantity' => $quantity,
'minimum' => $product_query['minimum'],
'maximum' => $product_query['maximum'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $quantity,
'tax_class_id' => $product_query['tax_class_id'],
'weight' => $product_query['weight'],
'weight_class' => $product_query['weight_class'],
'length' => $product_query['length'],
'width' => $product_query['width'],
'height' => $product_query['height'],
'length_class' => $product_query['length_class'],
'ship_individually' => $product_query['ship_individually'],
'shipping_price' => $product_query['shipping_price'],
'free_shipping' => $product_query['free_shipping'],
'sku' => $product_query['sku']
);
Then open core/lib/order and add sku there (line 266):
$product_data[] = array(
'product_id' => $product['product_id'],
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'download' => $product['download'],
'quantity' => $product['quantity'],
'price' => $product['price'],
'sku' => $product['sku'],
'total' => $product['total'],
'tax' => $this->tax->calcTotalTaxAmount($product['total'],$product['tax_class_id']),
'stock' => $product['stock']);
now you can see sku on your template, i mean storefront/view/default_html5/template/pages/checkout/confirm.tpl ...or old default template
-
thank you so so much.
i have do it and this work.
i have try to make it work on other file, on this file in admin panel: admin\view\default\template\responses\sale\order_invoice.tpl
so when buyer will make an order i will go to the admin panel, i will press on print invoice and i will see the SKU
so i have add this code to the file: order_invoice.tpl
<?php echo $product['sku']; ?>
and i have added this code to this file: admin\controller\pages\sale\order.php
'sku' => $order_product['sku'],
to the line: 354
what i am doing wrong?
and how to make this work?
Big Thanks
-
i think you try to edit wrong controller.
admin\view\default\template\responses\sale\order_invoice.tpl
and controller is "response" too - admin/controller/responses/sale/invoice.php
-
I have try this but its not working any idia why?
-
in the file: invoice.php
i make this change on the line: 138
$product_data[ ] = array(
'name' => $product[ 'name' ],
'model' => $product[ 'model' ],
'sku' => $product[ 'sku' ],
'option' => $option_data,
'quantity' => $product[ 'quantity' ],
'price' => $this->currency->format($product[ 'price' ], $order_info[ 'currency' ], $order_info[ 'value' ]),
'total' => $this->currency->format($product[ 'total' ], $order_info[ 'currency' ], $order_info[ 'value' ])
);
and in the file: order_invoice.tpl
i put this: <?php echo $product['model'] . $product['sku']; ?>
in line: 72
this don't work what is wrong?
-
i digged into code and found that order data does not contain sku.. i can't give you quick solution right now.
-
Ok please when you will have this cost post it here I really need that code
Thank you so much in advance
-
There are 2 solutions but both require coding:
1. Based on the product details in the order, load product SKU and Attributes SKUs.
Need to change: Controllers, Models and template on admin side. Not visible to customers.
2. Add SKU details to the order table and display in order details screens.
Need to change: Admin Controllers, Models and template on admin side, order creation controller on storefront side. And finally alter order tables to add these details.
-
In few hours I will give you a code the join tables and give me the SKU but I want this code will be transformed to abantecart code and not custom code.
And yes I need that it will be invisible to user.
-
this is the code that work on the file:
$select_ab_order_products = mysql_query ("SELECT * FROM ab_order_products INNER JOIN ab_products ON ab_order_products.product_id = ab_products.product_id WHERE ab_order_products.order_id='$order_id'") or die ("can't select");
foreach ($products as $product) {
$get_row_product_id = mysql_fetch_array ($select_ab_order_products) ;
this code do the work but is not AbanteCart card, how can i put this so this will be like AbanteCart cart code and not custom code?
thanks
-
your code ignores sku that set to product option.
-
I make some change in my code so that is work very good
$connect_this = mysql_connect(DB_HOSTNAME,DB_DATABASE,DB_PASSWORD) or die("error connect");
$mysql_db = mysql_select_db("ismyvodc_mystore")or die("error db");
$get_orderid = $_GET['order_id'];
$select_ab_order_products = mysql_query("SELECT * FROM order_products INNER JOIN products ON order_products.product_id = products.product_id WHERE order_products.order_id='$get_orderid'") or die ("can't select");
and after this code:
<?php foreach ($order['product'] as $product) {
i put my code:
$get_row_product_id = mysql_fetch_array($select_ab_order_products);
and i put this to see the sku:
<?php echo $get_row_product_id['sku']; ?>
but i need this code will be AbanteCart code.
if you can please help me with that?
i send you an image that show you the sku.
all the code i put in the file: order_invoice.tpl
-
i said about product options... not product sku.
Abantecart allow to set sku for option too.
For ex. you have product with name "shoes". Shoes have 2 options: size and color. For all combination of this properties merchant can set different values of sku. that's why changing of core is difficult right now.
You showed me your custom, partial, solution.
Why do you don't change method getOrderProducts() on file public_html/admin/model/sale/order.php ?
it used by sale/invoice.php controller.
FYI. you don't need to create new connection to database. Instance of db-class is already in memory.
you can do
$this->db->query($sql)
in any controllers and models
or
$registry = Registry::getInstance()
$registry->get('db')->query(sql);
everywhere in code
But personally i prefer to create custom extension with hooks of controllers.. this approach saves your changes after cart upgrade.
-
thank you so much for this, this is want i need.
i have the code to select db SELECT * FROM order_products INNER JOIN products ON order_products.product_id = products.product_id WHERE order_products.order_id='$get_orderid
can you show me how to put my code to this:
$this->db->query($sql)
thanks again very very much
-
$result = $this->db->query("SELECT * FROM order_products INNER JOIN products ON order_products.product_id = products.product_id WHERE order_products.order_id='".(int)$order_id."'" );
var_dump($result->rows);
$result->rows - is array with all rows.
-
i put this on invoice.php
$result = $this->db->query("SELECT * FROM order_products INNER JOIN products ON order_products.product_id = products.product_id WHERE order_products.order_id='".(int)$order_id."'" );
foreach ($result->rows as $product) {
$product['sku'];
}
echo $product['sku'];
and i see the sku at the top of the page so it work
but when i put the line into: order_invoice.tpl - i don't see the sku why is that?
what i am doing wrong?
echo $product['sku'];
-
try to write
echo $orders['products']['sku'];
controller $this->data['orders'] become $orders variable inside tpl..
-
So sorry but its don't work.
I will use my code for this.
The best way I see to use a AbanteCart cart code is when users make an order it will put in do database the SKU then is no problem to get the data.