- Posts: 25
- Thank you received: 1
Displaying product image in shopping cart
12 years 10 months ago #131916
by acwilan
Displaying product image in shopping cart was created by acwilan
I am building a custom template for hikashop. I have a menu item that leads to the cart display. So I'm overriding the com_hikashop/cart/showcart.php file. The thing is that I need to display the product image, which I don't see in the code. I do a
(inside the
code), but I get no images in the fields.
-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : 2.2.1
-- Joomla version -- : 3.2
-- PHP version -- : 5.3
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
Code:
var_dump($cart)
Code:
foreach($this->rows as $cart)
-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : 2.2.1
-- Joomla version -- : 3.2
-- PHP version -- : 5.3
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
Please Log in or Create an account to join the conversation.
12 years 10 months ago #131936
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Replied by Jerome on topic Displaying product image in shopping cart
Hi,
The cart does just contains information about "items". An item is a product in the cart, it does not contains the information of the product itself.
You have to load the product in order to access to some data, like the image, the description and other.
Regards,
The cart does just contains information about "items". An item is a product in the cart, it does not contains the information of the product itself.
You have to load the product in order to access to some data, like the image, the description and other.
Code:
$productClass = hikashop_get('class.product');
$product = $productClass->get( $product_id );
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: acwilan
Please Log in or Create an account to join the conversation.
12 years 10 months ago #132515
by acwilan
Replied by acwilan on topic Displaying product image in shopping cart
I tried doing that, but the "$product" variable contains information for the product, but not the images associated.
Code:
object(stdClass)#629 (52) {
["product_id"]=>
string(2) "11"
["product_parent_id"]=>
string(1) "0"
["product_name"]=>
string(43) "Ceremonial Huipil from Santa Maria de Jesus"
["product_description"]=>
string(750) "<p>...</p>"
["product_quantity"]=>
string(2) "-1"
["product_code"]=>
string(11) "01.1.11.2.J"
["product_published"]=>
string(1) "1"
["product_hit"]=>
string(2) "51"
["product_created"]=>
string(10) "1353972929"
["product_sale_start"]=>
string(1) "0"
["product_sale_end"]=>
string(1) "0"
["product_delay_id"]=>
string(1) "0"
["product_tax_id"]=>
string(1) "0"
["product_type"]=>
string(4) "main"
["product_vendor_id"]=>
string(1) "0"
["product_manufacturer_id"]=>
string(1) "0"
["product_url"]=>
string(0) ""
["product_weight"]=>
string(6) "10.000"
["product_keywords"]=>
string(0) ""
["product_weight_unit"]=>
string(2) "kg"
["product_modified"]=>
string(10) "1382738149"
["product_meta_description"]=>
string(0) ""
["product_dimension_unit"]=>
string(1) "m"
["product_width"]=>
string(5) "0.000"
["product_length"]=>
string(5) "0.000"
["product_height"]=>
string(5) "0.000"
["product_max_per_order"]=>
string(1) "0"
["product_access"]=>
string(3) "all"
["product_group_after_purchase"]=>
string(0) ""
["product_min_per_order"]=>
string(1) "0"
["product_contact"]=>
string(1) "0"
["product_last_seen_date"]=>
string(10) "1384478263"
["product_sales"]=>
string(1) "0"
["product_waitlist"]=>
string(1) "0"
["product_layout"]=>
string(0) ""
["product_average_score"]=>
string(1) "0"
["product_total_vote"]=>
string(1) "0"
["product_page_title"]=>
string(0) ""
["product_alias"]=>
string(0) ""
["product_price_percentage"]=>
string(9) "0.0000000"
["product_msrp"]=>
string(9) "0.0000000"
["product_canonical"]=>
string(0) ""
["product_age"]=>
string(37) "Approximately woven in the 2000’s "
["product_ethnic_group"]=>
string(10) "Kakchiquel"
["product_materials"]=>
string(28) "Cotton and mercerized cotton"
["product_origin_department"]=>
string(1) "1"
["product_origin_municipal"]=>
string(15) " Sacatepéquez "
["product_technique"]=>
string(26) "Woven on a back strap loom"
["product_use"]=>
string(17) "Ceremonial Huipil"
["product_size"]=>
string(30) "Approximately 34†x 38.5†"
["product_display_quantity_field"]=>
string(1) "0"
["alias"]=>
string(43) "ceremonial-huipil-from-santa-maria-de-jesus"
}
Please Log in or Create an account to join the conversation.
12 years 10 months ago #132549
by Xavier
Replied by Xavier on topic Displaying product image in shopping cart
Hi,
I think that you have to use the following code to get the image path:
I think that you have to use the following code to get the image path:
Code:
$productClass = hikashop_get('class.product');
$productClass->getProducts( $product_id );
$product = $productClass->products;
The following user(s) said Thank You: acwilan
Please Log in or Create an account to join the conversation.
12 years 10 months ago #132589
by acwilan
Replied by acwilan on topic Displaying product image in shopping cart
Thank you, that worked, although I had to code
since the var contained an array of products with one single product.
Now another question, how do I load the image helper? I have this code to display the images for the product
but it doesn't work since $this->image is not defined.
Code:
$productClass = hikashop_get('class.product');
$productClass->getProducts($cart->product_id);
$products = $productClass->products;
$product = reset($products);
since the var contained an array of products with one single product.
Now another question, how do I load the image helper? I have this code to display the images for the product
Code:
if (!empty($product->images)) {
$image = reset($product->images);
$width = $this->config->get('thumbnail_x');
$height = $this->config->get('thumbnail_y');
$this->image->checkSize($width,$height,$image);
if (!$this->config->get('thumbnail')) {
echo '<img src="'.$this->image->uploadFolder_url.$image->file_path.'" alt="'.$image->file_name.'" id="hikashop_main_image" style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle" />';
} else { ?>
<div class="hikashop_cart_product_image_thumb" >
<?php echo $this->image->display($image->file_path,true,$image->file_name,'style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"', '', $width, $height); ?>
</div><?php
}
}
but it doesn't work since $this->image is not defined.
Please Log in or Create an account to join the conversation.
12 years 10 months ago #132636
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Replied by Jerome on topic Displaying product image in shopping cart
Hi,
Regards,
Code:
$this->image = hikashop_get('helper.image');
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: acwilan
Please Log in or Create an account to join the conversation.
12 years 10 months ago #132936
by acwilan
Replied by acwilan on topic Displaying product image in shopping cart
Thanks, that did the work.
Cheers,
Cheers,
Please Log in or Create an account to join the conversation.
Time to create page: 0.206 seconds