Is there as way to display the vendor's name with the productin the cart?
2 years 2 months ago - 2 years 2 months ago #362061
by jazzmang
-- HikaShop version -- : 5.1.0
-- HikaMarket version -- : 4.1.1
-- Joomla version -- : 4.4.6
-- PHP version -- : 8.1.29
On the product page, when "Sold by" is enabled, it displays "Sold by <vendor name>.
Is there a way to display the vendor's name in cart/show.php next to each product's name?
I thought it would be called via:
The name appears in emails and the backend order, but we want to display it in the cart and checkout.
Thanks!
-- HikaMarket version -- : 4.1.1
-- Joomla version -- : 4.4.6
-- PHP version -- : 8.1.29
On the product page, when "Sold by" is enabled, it displays "Sold by <vendor name>.
Is there a way to display the vendor's name in cart/show.php next to each product's name?
I thought it would be called via:
Code:
<?php
if(!empty($this->extra_data['products'])) {
foreach($this->extra_data['products'] as $key => $content) {
?> <td class="hikashop_order_item_<?php echo $key; ?>_value"><?php
if(isset($product->extra_data[$key]))
echo $product->extra_data[$key];
?>
The name appears in emails and the backend order, but we want to display it in the cart and checkout.
Thanks!
Last edit: 2 years 2 months ago by jazzmang. Reason: Added code reference
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362066
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 Is there as way to display the vendor's name with the productin the cart?
Hello,
That's right, HikaMarket does load the vendor data during "product listing" but it doesn't load them during the "cart load" or "cart display".
Loading that data every time would be unoptimized since the cart is loaded a lot of time and you don't need to display the vendor name every time. For the "cart display", since you can have multiple displays, it could perform multiple time the same job.
It would require the right way to only load when necessary.
Otherwise, it would need to add some code in the HikaShop view in order to list the vendors in the cart and load their data.
You can see similar code in HikaShop, in the "product class" with the function "processViewFront" or in the "mail class" in the function "processOrdernotificationTemplate".
Regards,
That's right, HikaMarket does load the vendor data during "product listing" but it doesn't load them during the "cart load" or "cart display".
Loading that data every time would be unoptimized since the cart is loaded a lot of time and you don't need to display the vendor name every time. For the "cart display", since you can have multiple displays, it could perform multiple time the same job.
It would require the right way to only load when necessary.
Otherwise, it would need to add some code in the HikaShop view in order to list the vendors in the cart and load their data.
You can see similar code in HikaShop, in the "product class" with the function "processViewFront" or in the "mail class" in the function "processOrdernotificationTemplate".
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.
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362088
by jazzmang
Replied by jazzmang on topic Is there as way to display the vendor's name with the productin the cart?
We have the cart set to limit to one vendor, so I really only need to display it once.
Does that make a difference in avoiding multiple calls or in how to handle adding the extra code?
Does that make a difference in avoiding multiple calls or in how to handle adding the extra code?
Please Log in or Create an account to join the conversation.
2 years 2 months ago - 2 years 2 months ago #362089
by jazzmang
I've done a text search for those function names and cannot find them.
I looked in classes/product.php and classes/mail.php, too, but did not find them either.
Can you point me to where these functions are in 5.1.0?
Replied by jazzmang on topic Is there as way to display the vendor's name with the productin the cart?
Jerome wrote: You can see similar code in HikaShop, in the "product class" with the function "processViewFront" or in the "mail class" in the function "processOrdernotificationTemplate".
I've done a text search for those function names and cannot find them.
I looked in classes/product.php and classes/mail.php, too, but did not find them either.
Can you point me to where these functions are in 5.1.0?
Last edit: 2 years 2 months ago by jazzmang.
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362093
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 Is there as way to display the vendor's name with the productin the cart?
Hello,
We're talking about HikaMarket ; not HikaShop.
HikaMarket 5.1.0 doesn't exist, yet.
www.hikashop.com/support/documentation/1...arket-changelog.html
Regards,
We're talking about HikaMarket ; not HikaShop.
HikaMarket 5.1.0 doesn't exist, yet.
www.hikashop.com/support/documentation/1...arket-changelog.html
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: jazzmang
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362113
by jazzmang
Replied by jazzmang on topic Is there as way to display the vendor's name with the productin the cart?
Sorry, I misunderstood which software classes you were referencing.
I was thinking of HikaShop because the ultimate target was the shopping cart view.
I believe I got it worked out to display what I wanted.
In case someone else was interested, this is what I came up with:
I was thinking of HikaShop because the ultimate target was the shopping cart view.
I believe I got it worked out to display what I wanted.
In case someone else was interested, this is what I came up with:
Code:
$db = JFactory::getDBO();
$app = JFactory::getApplication();
$config = hikamarket::config();
$vendor_id = $product->product_vendor_id;
$query = 'SELECT * FROM '.hikamarket::table('vendor').' WHERE vendor_id = ' . $vendor_id;
$db->setQuery($query);
$vendor = $db->loadObject();
$vendor->alias = (empty($vendor->vendor_alias)) ? $vendor->vendor_name : $vendor->vendor_alias;
$vendorLink = '<a href="'.hikamarket::completeLink('vendor&task=show&cid=' . $vendor->vendor_id . '&name=' . $vendor->alias ).'">' . $vendor->vendor_name . '</a>';
echo '<br/><span class="hikamarket_vendor">' .JText::sprintf('SOLD_BY_VENDOR', $vendorLink). '</span>';
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362114
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 Is there as way to display the vendor's name with the productin the cart?
Hello,
For optimisation, the best is to perform a loop in order to collect all vendors.
Then load all vendors of your cart
Then in your listing you can retrieve the vendor
And display its name and generate the SEF URL with alias.
By doing that, you will have just one SQL query to load all vendors ; otherwise you are doing one SQL query per item in the cart.
Regards,
For optimisation, the best is to perform a loop in order to collect all vendors.
Code:
$vendor_ids = [1 => 1];
foreach($cart->products as $product) {
$vendor_id = (int)$product->product_vendor_id;
if($vendor_id > 0)
$vendor_ids[$vendor_id] = $vendor_id;
}
Code:
$query = 'SELECT vendor_id, vendor_name, vendor_alias FROM '.hikamarket::table('vendor').' WHERE vendor_id IN ('.implode(',', $vendor_ids).')';
$db = JFactory::getDBO();
$db->setQuery($query);
$vendors = $db->loadObjectList('vendor_id');
Code:
$vendor = $vendors[(int)$product->product_vendor_id ?? 1];
By doing that, you will have just one SQL query to load all vendors ; otherwise you are doing one SQL query per item in the cart.
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.
Please Log in or Create an account to join the conversation.
Moderators: Obsidev
Time to create page: 0.198 seconds