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

jetpack_related_posts_headline

Change the headline for the Jetpack related posts