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 23:01
Change the headline for the Jetpack related posts

jetpack_related_posts_headline

Change the headline for the Jetpack related posts

@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:59
Add out of stock flash text above featured image on single product page

Add out of stock flash text above featured image on single product page

If you have out of stock flash displayed on product catalog pages, but not on single product pages, you can follow my instructions to fix this.

Installation

  1. Copy over the code from functions.php to your WordPress copy of that file.
  2. Use Chrome dev tools to identify the class of div which is used to output 'Out of stock' flash on products category page of your website.
  3. Update line 6 printf( '%s', __( 'Out of Stock', 'Avada' ) ); with your div class details. Keep in mind: The div class used in this file does belong to Avada and may not work on other themes.
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:58
If you have set up shipping classes and assigned products to your shipping categories, then you can see here how to add fees for products from specific shipping classes.

Add fees for specific shipping class categories

If you have set up shipping classes and assigned products to your shipping categories, then you can see here how to add fees for products from specific shipping classes.

Installation

  1. Copy over the code from functions.php to your functions.php copy of WordPress site.
  2. You can remove lines 40-45.
  3. For each shipping class you would like to add fee for, copy and paste lines 46-48.
  4. Now simply update 'your-shipping-class-slug-here' with your shipping class slug, 'Any text you would like to see as fee heading :' with your text and $fixed with your preferred price.
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:56
Add fee for specific products while adjusting the shipping costs in the cart

Add fee for specific products while adjusting the shipping costs in the cart

If you have a specific product that you would like to have a fixed fee for and adjust the shipping cost not to take that product into account accordingly, then you need the code from this repository. There are two seperate functions involved:

  1. function wc_ninja_manipulate_shipping which takes care of adjusting the shipping cost not to take into account a particular vendor products or product
  2. function woocommerce_custom_surcharge that adds $30 surcharge fee below the shipping methods on its own line. Keep in mind: I am using the Table Rate Shipping plugin as well as my shipping costs are based upon order total for this example.

Installation for one product

  1. Update line 27 with your own product ID.
  2. Update line 40 by removing $tsar_check || as you only need to check for a product.
  3. Update line 42 by removing - $tsar_products_total.
@WhiteHatJoker
WhiteHatJoker / README.md
Created October 18, 2021 22:55
If you are not satisfied with the amount of menu areas or widget areas provided by your theme, you can use the code from this repository to add extra menus or widgets or both.

Adding Extra Menus or Widgets

If you are not satisfied with the amount of menu areas or widget areas provided by your theme, you can use the code from this repository to add extra menus or widgets or both.

Installation for Menus

  1. Copy the lines 3-13 from functions.php of current repository and place it in your functions.php file.
  2. In your template file, wherever you would like your custom menu to appear add the following <?php wp_nav_menu( array('menu' => 'Header Menu' )); ?>.
  3. If you want to add more than one custom menu just add new line into an array in place of comments on line 8, for example, , 'footer-menu' => __( 'Footer Menu' ).

Installation for Widgets

@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.
@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: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
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: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")) {