Skip to content

Instantly share code, notes, and snippets.

@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Hide shipping when discount rules free shipping is available
Created July 12, 2021 09:59
Woo Discount Rules v2 - Hide shipping when discount rules free shipping is available
/**
* Hide shipping rates when discount rules free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
@DeveloperWil
DeveloperWil / woocommerce-add-extra-email-recipient-completed-order
Created March 8, 2021 22:48
WooCommerce: Add an extra email recipient to the email sent when an order has been completed
/**
* Add extra emails to the WC email sent when an order has been completed.
*
* Make sure you separate multiple emails with a comma.
*
* @param $recipient
* @param $object
* @return string
*/
function zpd_wc_extra_email_recipient( $recipient, $object ): string {
@blogjunkie
blogjunkie / functions.php
Last active November 24, 2021 09:52
Add 'Awaiting pre-order' custom status to WooCommerce with bulk edit and custom status color
<?php // Don't copy this line
/**
* Add 'Awaiting pre-order' custom status
*
* 1. Register new order status
* 2. Add to list of WC order statuses
* 3. Add your custom bulk action in dropdown
* 4. Bulk action handler
* 5. Admin notices for bulk action
@brianleejackson
brianleejackson / scroll-sticky-widget-no-jquery.css
Last active October 16, 2020 14:28
Scroll sticky sidebar WordPress widget with no jQuery
@media (min-width: 769px) {
.site-content {
display: flex;
}
.inside-right-sidebar {
height: 100%;
}
.inside-right-sidebar aside:last-child {
position: -webkit-sticky;
position: sticky;
@isaumya
isaumya / remove-woocommerce-bloat-marketing-hub.md
Last active April 30, 2024 12:26
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

@vyskoczilova
vyskoczilova / woocommerce_my_account_orders_pagination_setting.php
Last active February 1, 2024 09:22
WooCommerce: My Account Orders Pagination - per page setting
<?php // don't copy this line
/**
* @snippet WooCommerce: My Account Orders Pagination - per page setting
* @source https://kybernaut.cz/?p=2896
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @testedwith WordPress 5.2 & WooCommmerce 3.6.2
*/
// -------------------
function kbnt_my_account_orders( $args ) {
/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function rd_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}
/*
@robin-scott
robin-scott / htaccess
Created October 19, 2018 08:37
Deny access to wp-admin BUT allow ajax to be used in WordPress
// Add this to an .htaccess file at the top of the wp-admin directory to lock down this section of your site to only trusted IP addresses - BUT still allow ajax access
// By Robin Scott of Silicon Dales - details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
Order Deny,Allow
Deny from all
@maddisondesigns
maddisondesigns / functions.php
Last active February 7, 2024 13:42
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@blakemiller99
blakemiller99 / wp-remove-posts-type
Last active November 23, 2022 13:52
Remove Posts from WordPress
// ************* Remove default Posts type since no blog *************
// Remove side menu
add_action( 'admin_menu', 'remove_default_post_type' );
function remove_default_post_type() {
remove_menu_page( 'edit.php' );
}
// Remove +New post in top Admin Menu Bar