{"id":2199,"date":"2024-03-01T09:53:23","date_gmt":"2024-03-01T09:53:23","guid":{"rendered":"https:\/\/wpshortcode.org\/?p=2199"},"modified":"2024-03-01T09:53:24","modified_gmt":"2024-03-01T09:53:24","slug":"woo-empty-cart-button","status":"publish","type":"post","link":"https:\/\/wpshortcode.org\/woo-empty-cart-button\/","title":{"rendered":"Empty Cart Button for WooCommerce Shortcode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Below, you&#8217;ll find a detailed guide on how to add the <strong>Empty Cart Button for WooCommerce Shortcode<\/strong> to your WordPress website, including its <strong>parameters<\/strong>, <strong>examples<\/strong>, and <strong>PHP function code<\/strong>. Additionally, we&#8217;ll assist you with common issues that might cause the Empty Cart Button for WooCommerce Plugin shortcode not to show or not to work correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting, here is an overview of the Empty Cart Button for WooCommerce Plugin and the shortcodes it provides:<\/p>\n\n\n<p>    <div class=\"plugin-info-box\">\n        <div class=\"top-main\">\n            <!-- SVG Image -->\n            <div class=\"plugin-image\">\n                <img decoding=\"async\" src=\"https:\/\/s.w.org\/plugins\/geopattern-icon\/virtue-toolkit.svg\" alt=\"Plugin Icon\" \/>\n            <\/div>\n            \n            <div class=\"plugin-descriptive-part\">\n                <!-- Plugin Name with Link -->\n\n                    <a class=\"plugin-title\" href=\"https:\/\/wordpress.org\/plugins\/woo-empty-cart-button\" target=\"_blank\" rel=\"noopener\">\n                        Empty Cart Button for WooCommerce                    <\/a>\n\n\n                <!-- Plugin Description -->\n                <p class=\"plugin-description\">\n                    &quot;Empty Cart Button for WooCommerce is a user-friendly plugin that allows you to effortlessly add an &#039;Empty Cart&#039; button in your WooCommerce store, enhancing customers&#039; shopping experience.&quot;                <\/p>\n            <\/div>\n        <\/div>\n\n        <!-- Rating and Additional Info -->\n        <div class=\"plugin-meta\">\n            <span class=\"plugin-rating\">\n                <span class='stars'>\u2605\u2605\u2605\u2605\u2729<\/span> (8)\n            <\/span>\n            <span class=\"plugin-active-installs\">\n                <strong>Active Installs<\/strong>: 3000+\n            <\/span>\n            <span class=\"plugin-tested\">\n                <strong>Tested with<\/strong>: 6.2.0            <\/span>\n            <span class=\"plugin-php-version\">\n                <strong>PHP Version<\/strong>: false            <\/span>\n        <\/div>\n\n        <!-- List of Included Shortcodes -->\n        <div class=\"plugin-shortcodes\">\n            <strong>Included Shortcodes:<\/strong>\n            <ul>\n                <li>[wec_button]<\/li>            <\/ul>\n        <\/div>\n    <\/div>\n    <\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Empty Cart Button for WooCommerce [wec_button] Shortcode<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8216;wec_button&#8217; shortcode is part of the Woo-Empty-Cart-Button plugin. It creates an &#8220;Empty Cart&#8221; button on your WooCommerce site. \n\n\n\nThe shortcode checks the WooCommerce version and gets the appropriate cart URL. It retrieves the custom &#8216;Empty Cart&#8217; text from the plugin options. If no text is defined, it defaults to &#8216;Empty Cart&#8217;. The button links to the cart URL with an &#8217;empty-cart&#8217; parameter, which triggers the cart clearance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode<\/strong>: <code>[wec_button]<\/code><\/p>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Examples and Usage<\/h3>\n\n\n<p><strong>Basic example<\/strong> &#8211; A simple usage of the &#8216;wec_button&#8217; shortcode to create an empty cart button.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[wec_button \/]<\/code><\/pre>\n\n\n<p>For more advanced examples, you can use the &#8216;wec_button&#8217; shortcode with different parameters. Although the shortcode doesn&#8217;t directly support additional parameters, you can modify the text displayed on the button by changing the &#8216;wecb_text&#8217; option in your WordPress settings.<\/p>\n<p><strong>Advanced example<\/strong> &#8211; Changing the text displayed on the empty cart button by modifying the &#8216;wecb_text&#8217; option in your WordPress settings.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">update_option( 'wecb_text', 'Clear Shopping Cart' );<\/code><\/pre>\n\n\n<p>Then, you can use the &#8216;wec_button&#8217; shortcode as usual, and it will display the new text:<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[wec_button \/]<\/code><\/pre>\n\n\n<p>Please note that this is a PHP code, and it should be added in your theme&#8217;s functions.php file or a site-specific plugin. Also, remember to replace &#8216;Clear Shopping Cart&#8217; with the text you want to display on the button.<\/p>\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PHP Function Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In case you have difficulties debugging what causing issues with <code>[wec_button]<\/code> shortcode, check below the related PHP functions code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode line<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_shortcode( 'wec_button', array( $this, 'wec_create_button_shortcode' ) );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode PHP function<\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; light: false; title: ; toolbar: true; notranslate\" title=\"\">\nfunction wec_create_button_shortcode() {\n\t\t\tglobal $woocommerce;\n\n\t\t\t\/\/ Check for deprecation notices\n\t\t\tif ( version_compare( $woocommerce-&gt;version, &#039;2.5&#039;, &quot;&lt;=&quot; ) ) {\n\t\t\t\t$cart_url = $woocommerce-&gt;cart-&gt;get_cart_url();\n\n\t\t\t} else {\n\t\t\t\t$cart_url = wc_get_cart_url();\n\t\t\t}\n\n\t\t\t$getEmptytext = get_option( &#039;wecb_text&#039; );\n\t\t\t$emptyTxt     = ! empty( $getEmptytext ) ? $getEmptytext : &#039;Empty Cart&#039;;\n\n\t\t\tif ( empty( $_GET ) ) {\n\t\t\t\treturn &#039;&lt;a class=&quot;button wecb_emptycart&quot; href=&quot;&#039; . $cart_url . &#039;?empty-cart=clearcart&quot;&gt;&#039; . sprintf( __( &#039;%s&#039;, &#039;woo-empty-cart-button&#039; ), $emptyTxt ) . &#039;&lt;\/a&gt;&#039;;\n\t\t\t} else {\n\t\t\t\treturn &#039;&lt;a class=&quot;button wecb_emptycart&quot; href=&quot;&#039; . $cart_url . &#039;?empty-cart=clearcart&quot;&gt;&#039; . sprintf( __( &#039;%s&#039;, &#039;woo-empty-cart-button&#039; ), $emptyTxt ) . &#039;&lt;\/a&gt;&#039;;\n\t\t\t}\n\t\t}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Code file location<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">woo-empty-cart-button\/woo-empty-cart-button\/woo-empty-cart-button.php<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you&#8217;ve learned how to embed the <strong>Empty Cart Button for WooCommerce Plugin shortcode<\/strong>, understood the parameters, and seen code examples, it&#8217;s easy to use and debug any issue that might cause it to &#8216;not work&#8217;. If you still have difficulties with it, don&#8217;t hesitate to leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below, you&#8217;ll find a detailed guide on how to add the Empty Cart Button for WooCommerce Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we&#8217;ll assist you with common issues that might cause the Empty Cart Button for WooCommerce Plugin shortcode not to show or not to work correctly. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"name":"Empty Cart Button for WooCommerce","slug":"","version":"1.4.0","author":"<a href=\"http:\/\/www.wpcodelibrary.com\">WPCodelibrary<\/a>","icons":"","plugin_tags":"{\"cart\":\"cart\",\"clear-cart\":\"clear-cart\",\"empty-cart\":\"Empty Cart\",\"empty-cart-button\":\"empty cart button\",\"woocommerce\":\"woocommerce\"}","author_profile":"https:\/\/profiles.wordpress.org\/wpcodelibrary\/","requires":"3.8","tested":"6.2.0","requires_php":"false","rating":82,"num_ratings":8,"active_installs":3000,"downloaded":20489,"last_updated":"2023-07-14 12:56am GMT","added":"2016-09-02","homepage":"http:\/\/www.wpcodelibrary.com","short_description":"This plugin simply adds &#039;Empty Cart&#039; button on cart page to clear cart using single click.","description":"\"Empty Cart Button for WooCommerce is a user-friendly plugin that allows you to effortlessly add an 'Empty Cart' button in your WooCommerce store, enhancing customers' shopping experience.\"","shortcodes":"[\"wec_button\"]","footnotes":""},"categories":[1],"tags":[],"class_list":["post-2199","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/comments?post=2199"}],"version-history":[{"count":1,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2199\/revisions"}],"predecessor-version":[{"id":2721,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2199\/revisions\/2721"}],"wp:attachment":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/media?parent=2199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/categories?post=2199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/tags?post=2199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}