简体   繁体   中英

Prestashop module debugging

I am newbie in Prestashop module development so sorry if it is a fool question... I have been reading the docs but I haven't found what I am looking for so here I go,

I'd like to show a message on the screen (just for debugging purpose) with different context vars and so forth when actionCartSave. Something similar to "console.log()" or "alert()" in js.

Impossible to add the product to the cart.

textStatus: 'parsererror'

errorThrown: 'SyntaxError: JSON Parse error: Unrecognized token '<''

responseText:

< xmp style="text-align: left;" > message: < /xmp>

*{

"products" : [...] *

I have already test this code:

public function hookActionCartSave( $params )
{
     ppp('message: ');
     return true;
}

...inside the module class definition but I am getting this error when I add a product to the cart:

I get this text in a different browser window.

So please, what is the best way to go?

Hope everything is clear. Thanks.

What you have done is correct, this error message is something thrown by javascript running in your browser since the additional information you are printing out using ppp isn't valid JSON.

If you use Chrome, use developer tools and select the Network tab. You will see the ajax call here. You can inspect this call in more detail by clicking on it.

不确定这是最佳选择,但我发现使用简单的调试工具很有用

throw new Exception('Custom message ' . $someVariable);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM