Skip to content

Instantly share code, notes, and snippets.

add_filter( 'woocommerce_product_get_stock_status', 'my_plugin_set_stock_status', 10, 2 );
add_filter( 'woocommerce_product_variation_get_stock_status', 'my_plugin_set_stock_status', 10, 2 );
/**
* Set maximum back orders.
*
* @param $stock_status string product stock status.
* @param $product integer product.
*
* @return mixed|string
@isaumya
isaumya / remove-woocommerce-bloat-marketing-hub.md
Last active April 10, 2024 12:45
Easily Remove WooCommerce Bloated Features like Marketing Hub from WordPress Admin Menu

Remove WooCommerce Bloated Features from WP Admin Menu

Recently WooCommerce has added a lot of improvements to the plugin which we really appriciate but at the same time a lot of bloated features has alos been added to the plugin like Marketing Hub, a completely useless menu taking extra space among the other important menu items. Now if you find Marketing Hub to be useful, you can keep it.

But just in case you are looking for a way to remove these features that you no longer need from your WordPress Admin menus, take a look at the following code snippets. Please note: though I will show you how you can remove the Marketing Hub from your WP Admin menu list completely and make sure WooCommerce doesn't execute codes for that feature you don't need, you can do the same for other WooCommerce features as well like Analytics.

How to remove Marketing Hub for WooCommerce <= v4.2

If you are using WooCommerce <= v4.2, you can simple add this one line of code in your theme's functions.php f

@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Created June 8, 2020 17:29
Booster for WooCommerce - Get info from Prices and Currencies by Country Module Options
<?php
add_action('wp_footer',function(){
if ( !WCJ()->modules['price_by_country']->is_enabled() ) {
return;
}
$country = WCJ()->modules['price_by_country']->core->get_customer_country_by_ip();
$group = WCJ()->modules['price_by_country']->core->get_customer_country_group_id();
$the_result = array('country'=>$country,'group'=>$group);
?>
<script>
<?php
if ( ! function_exists( 'de_woo_email_social_icons' ) ) {
function de_woo_email_social_icons( $icons ) {
echo '<ul class="de-social-icons">
<li><a href="#" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-instagram" aria-hidden="true"></i></a></li>
</ul>
@joshuatf
joshuatf / disable-woocommerce-admin.php
Created March 11, 2020 09:44
A plugin to disable the new WooCommerce Admin package in WooCommerce
<?php
/**
* Plugin Name: Disable WooCommerce Admin
* Description: This plugin disables the new WooCommerce Admin package in WooCommerce.
* Version: 1.0
*/
add_filter( 'woocommerce_admin_disabled', '__return_true' );
@Ruzgfpegk
Ruzgfpegk / wp-perf.md
Last active February 25, 2024 07:16
WordPress Performance & Development tips
@damiencarbery
damiencarbery / add-an-post-tracking-provider.php
Last active April 14, 2024 11:12
Tracking Info to WooCommerce order - Use CMB2 to add a custom metabox to add tracking information to WooCommerce orders. The information is then added to the "Completed Order" email. https://www.damiencarbery.com/2020/01/add-tracking-info-to-woocommerce-order/
<?php
/*
Plugin Name: Add Tracking Provider
Plugin URI: https://www.damiencarbery.com/
Description: Add new An Post (Irish postal service) as a tracking provider.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1.20240414
*/
@deeman
deeman / robots.txt
Last active February 4, 2020 10:29
Custom WordpPress/WooCommerce Robots.txt
User-agent: *
Disallow: /wp-admin/
Disallow: /?s=
Disallow: /search/
Allow: /admin/admin-ajax.php
Disallow: /cgi-bin/
Disallow: /wp-content/cache/
Disallow: /trackback/
Disallow: */trackback/
@or128
or128 / class-wc-structured-data.php
Last active February 7, 2020 13:46
Fixed Product Review Schema in WooCommerce (tested in v3.8)
<?php
/**
* Structured data's handler and generator using JSON-LD format.
*
* @package WooCommerce/Classes
* @since 3.0.0
* @version 3.0.0
*/
defined( 'ABSPATH' ) || exit;
function holiday_message_before_header() {
?>
<div class="header-block">
<?php echo do_shortcode( '[block id="YOUR BLOCK NAME"]' ); ?>
</div>
<?php
}
add_action( 'flatsome_before_header', 'holiday_message_before_header', 1 );