Skip to main content

need know a product name, category name, unit pric

12 years 8 months ago #145055 by aspkiddy
-- url of the page with the problem -- : http://127.0.0.139
-- HikaShop version -- : x2.2.3
-- Joomla version -- : Joomla! 2.5.11
-- PHP version -- : 5.4.5

I need know a product name, category name, unit price and quantity in an order :

In last step of transaction (in my end page (checkout/end.php)

I would write :

transaction Id = 1234
Site name = Toto Inc Web Site
bill total = 25.00
bill tax = 2.50
shipping = 5


Items :
product id = 123456789
product name = tostos
product category name = computer
product price = 10.00
product quantity = 1

Items :
product id = 323456789
product name = toptop
product category name = computer
product price = 7.50
product quantity = 1




I find the transaction Id, site name , bill total, bill tax and shipping but I can not find
information of each items : product id, product name, product category name, product price, product quantity

I put this code in my end.php :
Code:
$app = JFactory::getApplication(); $order_id = $app->getUserState('com_hikashop.order_id'); $orderClass = hikashop_get('class.order'); $this->order = $orderClass->loadFullOrder($order_id,true,false); $transaction_id = $order_id; $conf = JFactory::getConfig(); if(HIKASHOP_J30) { $siteName=$conf->get('sitename'); } else { $siteName=$conf->getValue('config.sitename'); } $site_name = $siteName; /* Site name */ $order_total = $this->order->order_full_price; $bill_total = $order_total; /* bill total */ $shipping_price_without_tax = $this->order->order_shipping_price-$this->order->order_shipping_tax; $shipping = $shipping_price_without_tax; /* shipping */ $taxes = $bill_total-$shipping-$this->order->order_subtotal_no_vat; $bill_tax = $taxes; /* bill tax */

But I added also information of Items transaction.

How can I have it ?

I tried it with this code but I have anything : :oops:
Code:
$product_id = $this->product->order_product_code; $product_name = $this->product->order_product_name; $product_category_name = $this->product->order->product_category->category_name; $product_price = $this->product->order_product_price+$this->product->order_product_tax; $product_quantity = $this->product->order_product_quantity;

but these variables are null :oops:
How can I get its values ? :unsure:

Thanks

Please Log in or Create an account to join the conversation.

12 years 8 months ago - 12 years 8 months ago #145078 by nicolas
You should do like that:
Code:
foreach($this->order->products as $product){ echo $product->order_product_name; }
Last edit: 12 years 8 months ago by nicolas.
The following user(s) said Thank You: aspkiddy

Please Log in or Create an account to join the conversation.

12 years 8 months ago #145197 by aspkiddy
Thanks Nicolas,

It works and I find : :cheer:

product id = 123456789
product name = tostos

product price without tax = 10.00
product quantity = 1

Code:
foreach($this->order->products as $product){ echo $product->order_product_code; //product id echo $product->order_product_name; //product name echo $product->order_product_price //product price without tax echo $product->order_product_quantity; //product quantity
But I can't find name of product category and product price with tax : :(

product category name = computer
product price without tax = 12.50

I tried for' product category name" ( = computer)
Code:
echo $product->order_product_category->order_category_name; echo $product->order_product_category->category_name; echo $product->product_category->order_category_name; echo $product->product_category->category_name;
I tried for' roduct price with tax" ( = computer)
Code:
echo $product->order_product_price+$product->order_product_tax;

But I have anything :(
How can I find its values for 'product category name' and 'product price with tax' ? :ohmy:

thanks

Please Log in or Create an account to join the conversation.

12 years 8 months ago #145239 by aspkiddy
I have a also an other problem with this : :ohmy:
When I have many items, for example 2, I see only last item : :blush:
In my cart :

1 Items :
product id = 123456789
product name = tostos

product price without tax = 10.00
product quantity = 1

2nd Items :
product id = 323456789
product name = toptop

product price without tax = 7.50
product quantity = 1


bill total = 25.00
bill tax = 2.50
shipping = 5.00


but on my screen, on last step of transaction (in my end page (checkout/end.php), I see only last item :

transaction Id = 1234
Site name = Toto Inc Web Site
bill total = 25.00
bill tax = 2.50
shipping = 5


product id = 323456789
product name = toptop
product category name = [missing value]
product price without tax = 7.50
product price with tax = [missing value]
product quantity = 1


I can not see any information on 1st item : missing 1st item :(
Code:
foreach($this->order->products as $product) { echo $product->order_product_code; //product id echo $product->order_product_name; //product name echo $product->order_product_price //product price without tax echo $product->order_product_quantity; //product quantity echo $product->order_product_price+$product->order_product_tax; //product price with tax[color=#ff0000] [missing value][/color] echo $product->order_product_category->order_category_name; //product category name" ( = computer) [color=#ff0000][missing value][/color] }

Can you help me

thanks

Please Log in or Create an account to join the conversation.

12 years 8 months ago #145258 by nicolas
echo $product->order_product_price+$product->order_product_tax;
will indeed display the full unit price.

For the category, it's more complex....You'll have to use the product_id attribute to load the category_id from the hikashop_product_category table and then do another query to load the category name from the hikashop_category table based on the category_id from the first query result.
The following user(s) said Thank You: aspkiddy

Please Log in or Create an account to join the conversation.

12 years 8 months ago #145763 by aspkiddy
Thanks Nicolas

It works

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum