Skip to content

Instantly share code, notes, and snippets.

View WhiteHatJoker's full-sized avatar

Ravshan Khudoyberdiev WhiteHatJoker

  • Elromco
  • Tashkent, Uzbekistan
View GitHub Profile
@WhiteHatJoker
WhiteHatJoker / README.md
Last active October 18, 2021 22:41
Insert the survey form to woocommerce thank you/order confirmation page

Showing a survey form on a thank you page

Insert the survey form to woocommerce thank you/order confirmation page

Installation

  1. Install the Formidable Forms plugin and create new form based on your needs and preferences. I had personally created the form that has fields such as name, email, subject(automatically filled with the post title), questions and hidden product page url (also automatically generated). All this info is setup to be sent to the admin email when the form is submitted by the user.
  2. Copy over the code from current repository to your functions.php replacing the following: in bracketsecho FrmFormsController::show_form(28, $key = 'frmprocontact2', $title=false, $description=true); as follows: (Your created Formidable Form ID, $key= 'Formidable Form Key', $title = true or false depending on wheter or not you would like to display the title set in form, $description = true or false depeneding on whether or not you would like to display description from the form).
  3. Note: You ca
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:37
Insert the ask us tab with the form on every single product page woocommerce.

Ask us tab on every woocommerce single product page

Insert the ask us tab with the form on every single product page.

Installation

  1. Create the survey form questions and customizations as you wish using the Formidable Forms plugin.
  2. Copy over the code from current repository to your functions.php replacing the values in bracketsecho FrmFormsController::show_form(28, $key = 'frmprocontact2', $title=false, $description=true); as follows: (Your created Formidable Form ID, $key= 'Formidable Form Key', $title = true or false depending on wheter or not you would like to display the title set in form, $description = true or false depeneding on whether or not you would like to display description from the form). Also, you can change the title of the tab and its order by modyfing 'title' => __( 'Your Tab Title here', 'woocommerce' ) and 'priority' => Your number here.
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:41
WC Vendors plugin already has a shortcode [wcv_vendorslist] for displaying the list of vendors, but it doesn't include the vendor pictures and it lacks box type styling. Therefore, we are going to create a new shortcode [wc_makers_list] for catalog which will also display vendor pics with the help of wp_user_avatar plugin.

Automatically generated catalog of vendors

WC Vendors plugin already has a shortcode [wcv_vendorslist] for displaying the list of vendors, but it doesn't include the vendor pictures and it lacks box type styling. Therefore, we are going to create a new shortcode [wc_makers_list] for catalog which will also display vendor pics with the help of wp_user_avatar plugin.

Installation

  1. Make sure you have installed WC Vendors and wp_user_avatar plugins.
  2. Copy over PHP code from functions.php into your WordPress functions.php.
  3. Copy vendor-list.php from the repository to your current theme folder/wc-vendors/front/ .
  4. Don't forget to update the profile pics for vendors by going to users->choosing vendor you wish to have a picture->Edit->Avatar->Image and uploading the image of the vendor you wish to appear on the vendors catalog. Keep in mind that now you can have pictures with different height and width resolutions(for example 180x240 instead of 180x180 as it was before installing wp_user_avatar). N
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:44
Changing sidebar on wc vendor page so that it is different from main shop page

Changing sidebar on wc vendor page so that it is different from main shop page#

If you are using WC Vendors Plugin you may notice that vendor pages inherit the shop page sidebar by default when most of the time they are irrelevant for the vendor pages. That is because WC Vendors is using the archive-product.php file which is also used for shop page views. To solve this issue we would have to update our archive-product.php with the conditional.

Installation

  1. Just copy the archive-product.php to your current theme folder/woocommerce/
  2. Create a separate sidebar for vendor pages under Aappearance->Widgets and then update the name of widget area 'makers' on line 120 of archive-product.php with your newly created widget area name.
  3. You have a new widget are that you could use now.

Manual installation if you have different version of archive-product.php or custom code there

Instead of the line 114 that was <?php do_action( 'woocommerce_sidebar' ); ?> put :

@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:45
Snippet to make search forms to search only for products

search_only_by_products

Snippet to make search forms to search only for products

Installation

Simply copy the repository code to your functions.php to make your sitewide search results show products.

@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:47
If you have installed WooCommerce Products Filter by realmag777 and set the shop base to display categories in woocommerce settings, you may notice that using woof filters from your main shop page brings products categories instead of filtered products result. This issue can be easily resolved by changing the woocommerce settings back to show al…

Fixing the issue of woof filtering on main shop page - woof filter results showing product categories instead of products

If you have installed WooCommerce Products Filter by realmag777 and set the shop base to display categories in woocommerce settings, you may notice that using woof filters from your main shop page brings products categories instead of filtered products result. This issue can be easily resolved by changing the woocommerce settings back to show all products on the main shop page, but, if you still would like to have product categories on main shop page, you would need to update your archive-product.php file.

Installation

Just copy the archive-product.php to your current theme folder/woocommerce/

Manual installation if you have different version of archive-product.php or custom code there

Instead of the line 67 that was <?php woocommerce_product_subcategories(); ?> put :

if ( !strpos($_SERVER['REQUEST_URI'], "swoof")) {
@WhiteHatJoker
WhiteHatJoker / README.md
Last active October 18, 2021 22:50
If you have installed the Woocommerce Products Filter (woof) plugin and you have custom page that you would like your users to return when they press the reset button no matter where they are, please follow my instructions. Keep in mind: Permalinks are turned on.

Woof reset button action

If you have installed the Woocommerce Products Filter (woof) plugin and you have custom page that you would like your users to return when they press the reset button no matter where they are, please follow my instructions. Keep in mind: Permalinks are turned on.

Instructions

  1. You need to have the woof plugin installed or downloaded.
  2. Download current repository and place the contents within woof plugin directory overwriting changes.
  3. Open views/woof.php and replace the http://your_link on line 479 data-link="http://your_link" with your url where you would like your users to go when they hit refresh.
  4. Enjoy!

Note

@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:51
If you have set the WooCommerce Settings -> Shop Page Display to show categories & subcategories, you may notice that your base shop page automatically shows all parent categories. This PHP snippet maybe useful if you would like to remove certain categories from the view on shop page.

Excluding certain categories from the base shop page

If you have set the WooCommerce Settings -> Shop Page Display to show categories & subcategories, you may notice that your base shop page automatically shows all parent categories. This PHP snippet maybe useful if you would like to remove certain categories from the view on shop page.

Installation

  1. Copy over the code in the current repository to your WordPress functions.php or woo-config.php files.
  2. Go to your Wordpress Admin Panel -> Products -> Categories and note down the slugs of categories that you would like to hide on your shop page.
  3. Place the noted slugs into the array of slugs on line 14 of functions.php
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:53
If you are using WC Vendors Plugin and you have set to show categories on the main shop page in woocommerce settings, you may notice the common issue that on individual vendor page we have categories displayed instead of the vendor products. That is because WC Vendors is using the archive-product.php file which is also used for shop page views. …

Fixing product categories on the wc vendor page

If you are using WC Vendors Plugin and you have set to show categories on the main shop page in woocommerce settings, you may notice the common issue that on individual vendor page we have categories displayed instead of the vendor products. That is because WC Vendors is using the archive-product.php file which is also used for shop page views. This issue can be easily resolved by changing the woocommerce settings to show all products on the main shop page, nevertheless, if you still would like to show vendor products on the wc vendor page while having product categories on main shop page, you would need to update your archive-product.php file.

Installation

Backup your archive-product.php and just copy repository archive-product.php to your current theme folder/woocommerce/

Manual installation if you have different version of archive-product.php or custom code there

Instead of the line 67 (that was `

@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:54
Add fee for products from specific vendor in cart

Adding a fee for a specific vendor in cart

Add fee for products from specific vendor in cart

Installation

  1. Copy the repository code into your functions.php file replacing line 5 $fixed=30; with your desired fee and line 11 if ($values['data']->post->post_author == 40) { 40 with id of the vendor you would like to add a fee for. Keep in mind that the code in this repository adds one instance of fixed fee no matter how many products from the specific vendor is in the cart.