This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display WooCommerce shop, category and tag description also on next pages, see https://gist.github.com/Willem-Siebe/c883eeb2eefb5eea82ab. | |
function woocommerce_product_archive_description() { | |
if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) >= 0 ) { | |
$shop_page = get_post( wc_get_page_id( 'shop' ) ); | |
if ( $shop_page ) { | |
$description = apply_filters( 'the_content', $shop_page->post_content ); | |
if ( $description ) { | |
echo '<div class="page-description">' . $description . '</div>'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This simple code demonstrates how to change automatically site language, according to the visitor's country. If you implement this script in your site it will open the page in the language of your visitor. | |
source: http://www.apphp.com/index.php?snippet=php-change-language-according-to-visitor-country | |
<?php | |
// prepare reload to local version according by first visit | |
session_start(); | |
$location_reload = isset($_SESSION["loc_reload"]) ? (bool)$_SESSION["loc_reload"] : false; | |
// prepare reload to local version according by first visit | |
if(!$location_reload){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function woo_seo_noindex_special_pages () { | |
global $post; | |
$woocommerce_pages = array('cart', 'checkout', 'order-received', 'order-tracking', | |
'my-account', 'logout', 'lost-password', 'mijireh-secure-checkout'); | |
$slug = get_post($post)->post_name; | |
if (in_array($slug, $woocommerce_pages)) { | |
echo '<meta name="robots" content="noindex,follow"/>' . "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customer processing order email | |
* | |
* @author WooThemes | |
* @package WooCommerce/Templates/Emails | |
* @version 1.6.4 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Settings Tab Demo | |
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a | |
* Description: A plugin demonstrating how to add a WooCommerce settings tab. | |
* Author: Patrick Rauland | |
* Author URI: http://speakinginbytes.com/ | |
* Version: 1.0 | |
* | |
* This program is free software: you can redistribute it and/or modify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add WooCommerce customer username to edit/view order admin page | |
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 ); | |
function woo_display_order_username( $order ){ | |
global $post; | |
$customer_user = get_post_meta( $post->ID, '_customer_user', true ); | |
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Product Enquiry Form: send email to post author instead of Site Admin | |
add_filter( 'product_enquiry_send_to', 'wc_product_enquiry_to_author', 10, 2 ); | |
function wc_product_enquiry_to_author( $email, $product_id ) { | |
$post_author_id = get_post_field( 'post_author', $product_id ); | |
$post_author_email = get_the_author_meta( 'user_email', $post_author_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reorder Checkout Fields | |
add_filter('woocommerce_checkout_fields','reorder_woo_fields'); | |
function reorder_woo_fields($fields) { | |
$fields2['billing']['billing_email'] = $fields['billing']['billing_email']; | |
$fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name']; | |
$fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name']; | |
$fields2['billing']['billing_country'] = $fields['billing']['billing_country']; | |
$fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1']; | |
$fields2['billing']['billing_address_2'] = $fields['billing']['billing_address_2']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data. | |
// See http://stackoverflow.com/a/32327810/470480 | |
// ---------------------- | |
/* | |
Instructions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customer new account email | |
* | |
* @author WooThemes | |
* @package WooCommerce/Templates/Emails | |
* @version 1.6.4 | |
*/ | |
// load customer data and user email into email template |