Skip to content

Instantly share code, notes, and snippets.

@jessepearson
jessepearson / wc_auto_complete_virtual.php
Created July 4, 2016 20:38
Auto Complete all WooCommerce virtual orders
<?php // only copy this line if needed
/**
* Auto Complete all WooCommerce virtual orders.
*
* @param int $order_id The order ID to check
* @return void
*/
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {
@claudiosanches
claudiosanches / functions.php
Created May 11, 2016 20:27
WooCommerce - Use "Starting at" prefix for variable price range
<?php
/**
* Custom variable price HTML.
* Shows "Starting at" prefix with when min price is different from max price.
*
* @param stirng $price Product price HTML
* @param WC_Product_Variable $product Product data.
* @return string
*/
function cs_my_wc_custom_variable_price_html( $price, $product ) {
@mikejolley
mikejolley / functions.php
Created May 10, 2016 09:13
WooCommerce - Remove product data tabs and hook content in sequence instead
<?php // Do not include this if already open!
/**
* Remove existing tabs from single product pages.
*/
function remove_woocommerce_product_tabs( $tabs ) {
unset( $tabs['description'] );
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );
return $tabs;
@mikejolley
mikejolley / functions.php
Created May 6, 2016 10:05
WooCommerce - Change number of displayed upsells on product pages
add_filter( 'woocommerce_upsell_display_args', 'custom_woocommerce_upsell_display_args' );
function custom_woocommerce_upsell_display_args( $args ) {
$args['posts_per_page'] = 5; // Change this number
$args['columns'] = 5; // This is the number shown per row.
return $args;
}
@bradyvercher
bradyvercher / readme.md
Created April 27, 2016 21:34
Configure WordPress to send email through an SMTP server.

WordPress SMTP Configuration

Usage

  1. Install and activate the smtp-config.php file as a plugin or drop it in /mu-plugins.
  2. Define the necessary constants in wp-config.php.

Configuration Examples

MailHog

@corsonr
corsonr / more-recent-product.php
Created April 27, 2016 13:22
WooCommerce: display more recent version of a product notice
<?php
// Display Fields
add_action( 'woocommerce_product_options_related', 'woo_add_custom_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_fields_save' );
// Display notice on proeuct page
add_action( 'woocommerce_single_product_summary', 'woo_display_more_recent_product_notice', 10 );
@claudiosanches
claudiosanches / custom-my-account-endpoint.php
Last active April 30, 2024 03:05
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@unfulvio
unfulvio / disable-woothemes-updater-notice.php
Created April 13, 2016 21:35
Disable WooThemes Updater Notice
<?php
/*
* Plugin Name: Disable WooThemes Updater Notice
* Version: 1.0.0
* Plugin URI: https://github.com/unfulvio/
* Description: Disables the WooThemes Updater activation notice nag when the Updater is deactivated.
* Author: Fulvio Notarstefano
* Author URI: https://github.com/unfulvio/
* Requires at least: 4.0
* Tested up to: 4.5
@claudiosanches
claudiosanches / functions.php
Last active February 23, 2018 19:57
WooCommerce - Adding new "My account" registration fields
<?php
/**
* Add new register fields for WooCommerce registration.
*/
function wooc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
@mikejolley
mikejolley / gist:e73f9d061aaebd25ccdc
Created February 22, 2016 13:07
WooCommerce - Remove subtotal row.
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}