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
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: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: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: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' =&gt; __( 'Your Tab Title here', 'woocommerce' ) and 'priority' =&gt; Your number here.
@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