Skip to content

Instantly share code, notes, and snippets.

@justinstern
justinstern / wc-order-email-payment-instructions.php
Last active August 22, 2017 14:28
Adding some payment instructions to WooCommerce order processing email
<?php
// Add the following to your theme's functions.php:
add_action( 'woocommerce_order_status_pending_to_processing_notification', 'watch_for_processing_email', 5 );
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', 'watch_for_processing_email', 5 );
function watch_for_processing_email() {
// only add the instructions for processing type emails
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@BFTrick
BFTrick / woocommerce-display-country-code-in-currency.php
Last active December 14, 2023 00:01
Display the currency symbol with the currency code first
<?php
/**
* Plugin Name: WooCommerce Display Currency Code in Currency Symbol
* Plugin URI: https://gist.github.com/BFTrick/10681832
* Description: Add the currency code to the currency symbol in WooCommerce. Ex. USD $.
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@pjrvs
pjrvs / newslettercookie.html
Last active November 7, 2017 09:33
a jquery cookie that shows a signup form for people that aren't signed up and an alternate message for people that came from the list or signed up.
<!DOCTYPE html>
<html>
<head>
<title>jQuery Cookie + MailChimp</title>
<meta charset="utf-8">
</head>
<body>
<form action="XXX" method="post" class="signup">
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 8, 2017 19:29
Remove Shop page from WordPress SEO (Yoast) WooCommerce breadcrumb on is_product page, see http://wpquestions.com/question/showChrono/id/8603.
// Remove Shop page from WooCommerce breadcrumb on is_product page, see https://gist.github.com/Willem-Siebe/6f43704e8536fc308fc3.
function wsis_wpseo_breadcrumb_output( $output ){
if( is_product() ){
$from = ' » <span typeof="v:Breadcrumb"><a href="http://yoururl.com/shop/" rel="v:url" property="v:title">Producten</a></span>';
$to = '';
$output = str_replace( $from, $to, $output );
@Willem-Siebe
Willem-Siebe / invoice.php
Last active July 9, 2017 13:34
Add Order number besides invoicenumber to invoice (WooCommerce PDF Invoices & Packing Slips plugin), see http://wordpress.org/support/topic/invoice-number-vs-invoice-order?replies=27#post-5434747.
<!-- Add Order number besides invoicenumber to invoice (WooCommerce PDF Invoices & Packing Slips plugin), see https://gist.github.com/Willem-Siebe/c05bd7d2938e951b54bc -->
<span class="order-number-label"><?php _e( 'Order Number:', 'wpo_wcpdf' ); ?></span>
<span class="order-number"><?php $wpo_wcpdf->order_number(); ?></span><br />
@Willem-Siebe
Willem-Siebe / functions.php
Created May 23, 2014 08:09
The return to shop button in WooCommerce empty-cart.php goes to the shop archive page. However, if we don't want a shop page and leave this option unset in WooCommerce settings, we need this button to go to our homepage. See http://codex.wordpress.org/Function_Reference/get_home_url. For help on filters see http://dev.themeblvd.com/tutorial/filt…
// The return to shop button in WooCommerce empty-cart.php goes to the shop archive page. However, if we don't want a shop page and leave this option unset in WooCommerce settings, we need this button to go to our homepage. See https://gist.github.com/Willem-Siebe/c1d70aeef75a3e60ab15.
function wsis_woocommerce_return_to_shop_redirect() {
return get_home_url();
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wsis_woocommerce_return_to_shop_redirect' );
@Willem-Siebe
Willem-Siebe / invoice.php
Last active October 16, 2017 12:19
Add the three custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see http://wordpress.org/support/topic/adding-text-field-below-the-table.
<!-- Add the first custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see https://gist.github.com/Willem-Siebe/cf8474b5ca4e72880a04. -->
<?php if ( $wpo_wcpdf->get_extra_1() ): ?>
<div id="extra1">
<?php $wpo_wcpdf->extra_1(); ?>
</div>
<?php endif; ?>
<!-- Add the second custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see https://gist.github.com/Willem-Siebe/cf8474b5ca4e72880a04. -->
@dcondrey
dcondrey / dcWPFunctions.html
Last active June 10, 2017 13:01
My collection of custom functions for use with WP. Manipulating post content and titles, article content and titles, seo, cleanup, etc, misc..
<?php
/**
* Limit previous/next post title character length and append a ellipsis if trunicated
*/
$previous_post = get_adjacent_post( false, '', true );
$next_post = get_adjacent_post( false, '', false );
$previous_post_title= get_the_title($previous_post);
$next_post_title = get_the_title($next_post);
$max_length = 75;
$previous_post_length = strlen($previous_post_title);
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:35
Remove CSS from WooCommerce 2.1 and further, see http://jameskoster.co.uk/snippets/disable-woocommerce-styles/.
// Remove CSS from WooCommerce after version 2.1, see https://gist.github.com/Willem-Siebe/8c29bcfa791316165127.
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );