Skip to content

Instantly share code, notes, and snippets.

@markduwe
markduwe / README.md
Last active November 5, 2017 11:19
Woocommerce SMS notification

Find out your carrier and if they have an email to SMS service. It'll be something like [email protected].

Replace "your_sms_email" with that email address and insert the code block into your theme functions file.

It hooks into the new order function, so sends an SMS when a new order is created.

Useful as the WooComm app doesn't yet have push notifications and emails can sometimes take a while to come through.

@xlplugins
xlplugins / woocommerce_shipment_tracking_front_output_xlplugin.php
Last active May 29, 2019 10:19
A shortcode snippet prepare to output shipment tracking UI on WooCommerce Thank You page.
<?php
/**
* Shortcode snippet prepare to output shipment tracking UI on WooCommerce Thank You page.
* Required: WooCommerce Shipment Tracking - https://woocommerce.com/products/shipment-tracking/
* Required: NextMove - WooCommerce Thank You Page - xlplugins.com/woocommerce-thank-you-page-nextmove/
*/
function wc_shipment_tracking_by_xlplugin($atts) {
if (isset($_REQUEST['order_id']) && $_REQUEST['order_id'] != '') {
$html = '';
$order_id = $_REQUEST['order_id'];
@kloon
kloon / functions.php
Created October 9, 2017 12:25
WooCommerce hide refund reason from customer
<?php
/**
* Replace refund reason with generic Refund text.
*
* @param $total_rows
* @param $order
* @param $tax_display
* @return array
*/
function remove_public_facing_refund_reason( $total_rows, $order, $tax_display ) {
@lukecav
lukecav / functions.php
Created October 6, 2017 13:29
Stop customer IP from being saved in orders in WooCommerce
add_filter( 'update_post_metadata', 'wc_customer_ip_delete', 10, 3 );
function wc_customer_ip_delete( $null, $id, $key ) {
if ( '_customer_ip_address' === $key )
return FALSE;
return $null;
}
@devinsays
devinsays / customer-new-account.php
Created October 3, 2017 20:36
Sends new WooCommerce customers an account email that with their email address as a login rather than a username.
<?php
/**
* Customer new account email
*
* This template has been overriden to change account creation text.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 1.6.4
@lukecav
lukecav / functions.php
Created October 3, 2017 13:37
Send an email notification when order status change from pending to cancelled in WooCommerce
add_action('woocommerce_order_status_pending_to_cancelled', 'cancelled_send_an_email_notification', 10, 2 );
function cancelled_send_an_email_notification( $order_id, $order ){
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Sending the email
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
}
@lukecav
lukecav / functions.php
Created October 2, 2017 20:00
Store customers IP in order meta in WooCommerce
add_action( 'woocommerce_checkout_update_order_meta', 'wc_store_user_ip' );
function wc_store_user_ip( $order_id ) {
update_post_meta( $order_id, 'Customer IP', $_SERVER['REMOTE_ADDR'] );
}

Upload images to GitHub

  1. Create a new issue on GitHub.

  2. Drag an image into the comment field.

  3. Wait for the upload process to finish.

  4. Copy the URL and use it in your Markdown files on GitHub.

@neilgee
neilgee / prod-cat.php
Created October 1, 2017 07:19
WooCommerce Product Category Dropdown in Archive
<?php // <~ don't add me in
add_action( 'widgets_init', 'wb_extra_widgets' );
/**
* Register new Widget area for Product Cat sort dropdown.
*/
function wb_extra_widgets() {
register_sidebar( array(
'id' => 'prod_sort',
// Insert title above shop categories
add_action( 'wpex_hook_content_top', function() {
if ( is_tax( 'product_cat' ) ) {
echo '<h1 class="myprefix-woo-category-title">' . single_term_title( '', false ) . '</h1>';
}
}, 5 );