Skip to content

Instantly share code, notes, and snippets.

View Luminus's full-sized avatar

Luminus Olumide Alabi Luminus

View GitHub Profile
@Luminus
Luminus / gist:e5d8149df1c70ef121f07cd42d36e2c1
Last active June 12, 2017 13:00
Get MailCatcher to work with Nginx
location ~ \.php$ {
fastcgi_param PHP_VALUE "sendmail_path=/usr/bin/env PATH/TO/catchmail -f [email protected]";
}
@Luminus
Luminus / relocate_eu_vat.php
Created July 17, 2017 12:58
Change the position of the EU VAT Number field on the Checkout page
remove_action( 'woocommerce_after_checkout_billing_form', array( 'WC_EU_VAT_Number', 'vat_number_field' ) );
add_action( 'HOOK-YOU-WANT-TO-ADD-IT-TO', array( 'WC_EU_VAT_Number', 'vat_number_field' ) );
@Luminus
Luminus / functions.php
Last active July 26, 2019 22:40
Display the "Sold By: Vendor Name" of Product Vendors under the product name on single product page & Hide the original one
<?php
if ( class_exists( 'WC_Product_Vendors_Vendor_Frontend' ) ) {
add_action( 'woocommerce_single_product_summary', array( WC_Product_Vendors_Vendor_Frontend, 'add_sold_by_single' ), 5 );
}
@Luminus
Luminus / functions.php
Created November 20, 2017 06:27
Hide Coupon Form from the Cart & Checkout Pages if there's a Deposit Product in the Cart
<?php
// hide coupon form from the cart and checkout pages if there's a deposit product in the cart
function hide_coupon_field( $enabled ) {
if ( is_cart() || is_checkout() ) {
if ( class_exists( 'WC_Deposits_Cart_Manager' ) ) {
if ( WC_Deposits_Cart_Manager::has_deposit() ) {
$enabled = false;
}
}
@Luminus
Luminus / functions.php
Created December 5, 2017 05:36
Remove Related Products from the Single Product Page for Products in a Specific Category
<?php
add_action( 'wp', 'vn_remove_related_products' );
function vn_remove_related_products() {
// replace 'accessories' with the slug for your product category
if ( is_product() && has_term( 'accessories', 'product_cat' ) ) {
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
}
}
@Luminus
Luminus / functions.php
Created December 6, 2017 09:40
Disable specific payment gateways on a specific language version of your WooCommerce site that's running WPML
<?php
function wpml_filter_gateways($gateways){
if(ICL_LANGUAGE_CODE == 'fr') //Checks if the selected language is French.
unset($gateways['paypal']); //"remove" paypal
return $gateways; //returns the other payment methods.
}
add_filter('woocommerce_available_payment_gateways','wpml_filter_gateways',1);
@Luminus
Luminus / functions.php
Last active December 20, 2017 09:30
Automatically restore WooCommerce Stock when you cancel an order
class Luminus_Woocommerce_Auto_Stock_Restore {
function __construct() {
add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
// add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
// add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
// add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
}
@Luminus
Luminus / wc-site
Last active January 9, 2019 07:44
Setup a new WordPress site with WooCommerce and Storefront installed and activated. You must have Laravel Valet or Valet+ installed and also the WP CLI Valet Command - https://aaemnnost.tv/wp-cli-commands/valet/ and the WP-CLI Login Command - https:/
#!/bin/bash
# Function to display usage instructions when the command is used incorrectly
function usage {
echo "usage: wc-site <name> [--master]"
echo "e.g. wc-site gradient will create a site at https://gradient.test"
echo "The \"--master\" switch will install the current WooCommerce master from Github"
exit 1
}
@Luminus
Luminus / wp-clone
Last active December 7, 2018 11:19
Clone an existing local WordPress site to a new folder. You must be using Laravel Valet or Valet+ as your local development environment
#!/bin/bash
# Function to display usage instructions when the command is used incorrectly
function usage {
echo "usage: wp-clone <source> <destination>"
echo "<source> is the site you want to clone"
echo "<destination> is where you want to clone it to"
exit 1
}
@Luminus
Luminus / config.yml
Created February 19, 2018 14:21
My `~/.wp-cli/config.yml` file for bending WP-CLI and the WP-CLI Valet Command to my will
core config:
dbuser: root
dbpass: root
extra-php: |
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
define( 'WCS_DEBUG', true );