WISHLIST - Override the function

  • Posts: 57
  • Thank you received: 4
9 years 6 months ago #201081

Hi guys,

I need your help.
Can you tell me how can I override a function to wishlist?

For example, I have created a new plugin to override diferent views like product_page_view, listing view, compare view, mini-cart view, checkout view and now only less me the wishlist view.

To do that I have created a new plugin like:

class plgHikashopOverrideData extends JPlugin
{

function plgHikashopOverrideData(&$subject, $config)
{
...
}

# function to override diferent views in hikashop
function onHikashopBeforeDisplayView(&view)
{
...
if($view->getName() == 'product')
{
if($view->getLayout() == 'show')
{
// for product page
}
elseif($view->getLayout()=='compare')
{
// for compare page
}
else
{
// for other views
}
}
]

# function to cart and checkout
function onAfterCartProductsLoad(&cart)
{
...
}
}

and I have tried inside this functions to put for example if($view->getLayout() == 'wishlist') but I don't have any results.
Can you help me please, to discover where I can do that and what name of function I need to solve my problem?

Thanks.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #201082

Hi,

Why not use the views override system ?
Here is the documentation for that:
www.hikashop.com/support/support/documen...ize-the-display.html

Else the view name is "cart" and the layout is "showcart", but the same view is used for both cart and wishlist so you will have do to some checks to edit only the wishlist layout, or you can edit both.

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

  • Posts: 57
  • Thank you received: 4
9 years 6 months ago #201226

Hi,

Thanks for you answer.

Override the view isn't a option because I have an WebService to set the objects that we wan't.
For example, I'm setting the product prices, product quantities, disconts, stock and expedition from an external DB and get all this information with an Soap Webservice.
Everything works with all view, except wishlist view.
So, how can I set for example $row->elements (products) in wishlist using my plugin to override?

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
9 years 6 months ago #201245

Hi,

It's normal that you can't use the onHikashopBeforeDisplayView(&view) trigger to override that wishlist/cart view as it would require the addition of this attribute in the class of the file components/com_hikashop/views/cart/view.html.php :
var $triggerView = true;

But then you could simply call that onHikashopBeforeDisplayView trigger yourself from the showcart view override and you would be able to do that without hacking in the view.html.php file.

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

  • Posts: 57
  • Thank you received: 4
9 years 6 months ago #201384

Hi nocolas.

I'm sorry but I don't understood very well what you tried to explain.
Can you please explain better ou show me a sample to understand what you tried to said?

Thanks.

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

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
9 years 6 months ago #201387

Hi,

Edit the file "showcart" of the view "cart" via the menu Display>Views and add the code:

<?php
			JPluginHelper::importPlugin('hikashop');
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger('onHikashopBeforeDisplayView', array(&$this));
?>
at the beginning of the file and the onHikashopBeforeDisplayView function of your custom hikashop plugin will be called when you display the wishlist details page.

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

Time to create page: 0.071 seconds
Powered by Kunena Forum