Using $this when not in object context
-
Hi,
First of all thanks for a great plugin. There are some issues I came across:
1.) When adding a product, which has a limited stock of e.g. 1 to your basket and you already have it in your basket, WC will return an error (“You cannot add that amount to the cart — we have 1 in stock and you already have 1 in your cart.“). However, your plugin is not handling this error well and instead throwing the following PHP error:
PHP Fatal error: Using $this when not in object context in /home/kossmos/htdocs/shopclay.test/public_html/wp-content/plugins/woocommerce-ajax-add-to-cart-for-variable-products/woocommerce-ajax-add-to-cart-variable-products.php on line 124Changing the PHP code like below resolved this error:
//$this->json_headers(); header('Content-Type: application/json');2.) I was wondering if we could return the error in the JSON response, so the page does not have to reload to show it?
3.) Also as mentioned in an earlier issue,
woocommerce_params.ajax_loader_urlis (sometimes) undefined?4.) In the JS file I guess you should replace line 126
$(key).html(value);
with:
$(key).replaceWith(value);https://wordpress.org/plugins/woocommerce-ajax-add-to-cart-for-variable-products/
The topic ‘Using $this when not in object context’ is closed to new replies.