Apr 18

WooCommerce — How to clear cart content after payment

Sometimes you want to clear cart content.For example, if the customer was redirected back to your WooCommerce store after payment,you need to clear WooCommerce shopping cart to avoid dumplicated order.so how?

global $woocommerce; $woocommerce->cart->empty_cart(); 

Keep in mind the $woocommerce is a global variable. you need to explicitly declare before you can call it in function or methods.

To clear cart only for some special page, you can detect page with function is_page()  which you can pass any page title, ID or slug.

 

 

 

Apr 08

PHP — PHP Protocol https not supported or disabled in libcurl

While i was developing WooCommerce payment module for Pagbrasil gateway,i got a curl error msg as:

PHP Protocol https not supported or disabled in libcurl

To check if https protocol was supported by the server,i created a script called a.php and put <?php phpinfo(); ?> in it.From the curl section of the phpinfo page, i found  that https protocol were not listed. so the cURL was not built with SSL support.The only way is to recompile the php.