{"id":8663,"date":"2019-11-06T06:35:22","date_gmt":"2019-11-06T06:35:22","guid":{"rendered":"https:\/\/jdthomson.com\/?p=8663"},"modified":"2022-07-11T10:08:39","modified_gmt":"2022-07-11T10:08:39","slug":"wp-snippets-series-add-a-continue-shopping-button-on-cart-page","status":"publish","type":"post","link":"https:\/\/jdthomson.com\/wp-snippets-series-add-a-continue-shopping-button-on-cart-page\/","title":{"rendered":"Wp Snippets Series: Add A Continue Shopping Button On Cart Page."},"content":{"rendered":"

Hello Everyone<\/p>\n

\n

 <\/p>\n

Welcome back to the Jdthomson Newsroom and today we wanted to share with you how you could add a continue shopping button on cart page in a Woocommerce Store.<\/p>\n

 <\/p>\n

So there are times as a customer that once you have added your first product to the cart you get forward to the cart page and need to go back and this is a simple feature missing from a lot of stores, but what my seem simple could change your conversions and stop cart abandonment. Its one of the many basic features any eCom installation should have<\/p>\n

 <\/p>\n

Today i will show you show to add a continue shopping button on cart page of your Woo-commerce website.<\/p>\n

 <\/p>\n

Method 1: How to do it manually<\/h1>\n

Customising functions.php file<\/h3>\n

 <\/p>\n

What\u2019s functions.php file?:<\/h3>\n

functions.php is a template file in your WordPress theme that enables you to easily extend the features of your theme and WordPress installation. To extend the features, all you have to do is add certain code snippets to your functions.php file.<\/p>\n

 <\/p>\n

Add The Snippet To Your Functions.PHP File:<\/h3>\n

you can add snippets directly to your functions.php file. In addition, to retain the customisation even after upgrading your theme, you can create a child theme and insert the code within it.<\/p>\n

\r\n  add_action( \u2018woocommerce_before_cart_table\u2019, \u2018wc_add_continue_shopping_button_to_cart\u2019 );\r\nfunction wc_add_continue_shopping_button_to_cart() {\r\n $shop_page_url = get_permalink( woocommerce_get_page_id( \u2018shop\u2019 ) );\r\n \r\n echo \u2018<div class=\u201cwoocommerce-message\u201d>\u2019;\r\n echo \u2018 <a href=\u201c\u2019.$shop_page_url.\u2019\u201d class=\u201cbutton\u201d>Continue Shopping \u2192<\/a> Would you like some more goods?\u2019;\r\n echo \u2018<\/div>\u2019;\r\n}<\/code><\/pre>\n

 <\/p>\n

 <\/p>\n

Method 2: How To Do it W\/ Plugin<\/h1>\n

 <\/p>\n

Step 1:<\/b><\/p>\n

To add the code snippet below you can install a plugin called \u201c Code Snippets<\/a> \u201c an easy and simple way to run PHP code snippets on your WordPress <\/a> site. It removes the need to add custom snippets to your theme theme\u2019s functions.php file.<\/p>\n

 <\/p>\n

If you don\u2019t know what a snippet is it is a small chunk of code that you can use to extend the functionality of a WordPress <\/a> website.<\/p>\n

 <\/p>\n

Why use this plugin while most blogs say to add codes to your theme\u2019s functions.php file, which all can get rather messy. this plugin has an interface for adding snippets and actually running them on your site & Since you\u2019re not inserting the code in any theme files, you can preserve the customization on your site even after switching your theme.<\/p>\n

 <\/p>\n

Plugin LINK<\/a><\/p>\n

 <\/p>\n

If this is your first time here or you need help installing a plugin check out this article<\/p>\n<\/div>\n

 <\/p>\n

\n

Step 2:<\/b><\/p>\n

 <\/p>\n

Once the \u201c Code Snippets<\/a> \u201c plugin is active got to the left side menu and find code snippets. Press add new and then copy and paste the below code in the box and then specify a title, description, and tags for the snippets as reference for yourself down the line.<\/p>\n

 <\/p>\n

With Code Snippets<\/a> , you can activate or deactivate snippets, just like plugins. That way, in the future, you can easily figure out the purpose of each snippet you\u2019ve added.<\/p>\n

 <\/p>\n

How to Import Code Snippets<\/h1>\n

Look for the Snippets admin menu, from Snippets > Import.<\/p>\n

 <\/p>\n

Create an XML file by opening it up in either notepad or a code editor app, pasting in the code below and then saving an \u201c.XML\u201d file.<\/p>\n

 <\/p>\n

Once the file is ready select the XML file you want to import & follow these steps:<\/p>\n

 <\/p>\n

    \n
  1. Install the Code Snippets<\/a> plugin using the directions provided at the above link.<\/li>\n
  2. Go to \u2018Tools: Import\u2019 in the WordPress admin panel.<\/li>\n
  3. Click on the \u201c Code Snippets<\/a> \u201c importer in the list<\/li>\n
  4. Upload this file using the form provided on that page.<\/li>\n
  5. Code Snippets<\/a> will then import all of the snippets and associated information contained in this file into your site.<\/li>\n
  6. You will then have to visit the \u2018Snippets: All Snippets\u2019 admin menu and activate desired snippets.<\/li>\n<\/ol>\n

     <\/p>\n

    Code Snippet:<\/h1>\n

     <\/p>\n

    <snippets>\r\n  <snippet scope=\u201c2\u201d>\r\n    <name>Add a continue shopping button on cart page in WooCommerce<\/name>\r\n    <desc><\/desc>\r\n    <tags>continue, shopping, cart, woocommerce<\/tags>\r\n    <code>add_action( \u2018woocommerce_before_cart_table\u2019, \u2018wc_add_continue_shopping_button_to_cart\u2019 );\r\nfunction wc_add_continue_shopping_button_to_cart() {\r\n $shop_page_url = get_permalink( woocommerce_get_page_id( \u2018shop\u2019 ) );\r\n \r\n echo \u2018<div class=\u201cwoocommerce-message\u201d>\u2019;\r\n echo \u2018 <a href=\u201c\u2019.$shop_page_url.\u2019\u201d class=\u201cbutton\u201d>Continue Shopping \u2192<\/a> Would you like some more goods?\u2019;\r\n echo \u2018<\/div>\u2019;\r\n}\r\n<\/code>\r\n  <\/snippet>\r\n<\/snippets><\/code><\/pre>\n

     <\/p>\n

    Enjoy<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

    So there are times as a customer that once you have added your first product to the cart you get forward to the cart page and need<\/p>\n","protected":false},"author":1,"featured_media":8666,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"order-bump-settings":[],"_wpfnl_thankyou_order_overview":"on","_wpfnl_thankyou_order_details":"on","_wpfnl_thankyou_billing_details":"on","_wpfnl_thankyou_shipping_details":"on"},"categories":[274,214,223,213],"tags":[],"_links":{"self":[{"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/posts\/8663"}],"collection":[{"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/comments?post=8663"}],"version-history":[{"count":0,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/posts\/8663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/media\/8666"}],"wp:attachment":[{"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/media?parent=8663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/categories?post=8663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdthomson.com\/wp-json\/wp\/v2\/tags?post=8663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}