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: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

@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 `