Skip to content

Instantly share code, notes, and snippets.

@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:36
Display WooCommerce shop, category and tag description also on next pages. I can only changing it by declaring the same function name in my own functions.php, so that is what I did.
// 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>';
}
@apphp
apphp / gist:3c23b9cdbc42432afcd9
Created June 23, 2014 07:27
Change Language Automatically According to the Visitor Country
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){
@galbaras
galbaras / gist:6ad566fa9fd7dd8de1d5
Last active May 29, 2019 10:34
Make special WooCommerce pages "noindex,follow" when using Yoast SEO
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";
}
@vinacode
vinacode / customer-processing-order.php
Created July 1, 2014 10:05
WooCommerce email template
<?php
/**
* Customer processing order email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
@BFTrick
BFTrick / woocommerce-settings-tab-demo.php
Last active March 26, 2024 10:48
A plugin demonstrating how to add a WooCommerce settings tab.
<?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
@corsonr
corsonr / gist:c2781c9e0cc086c5047f
Created July 17, 2014 08:51
WooCommerce: Add customer username to edit/view order admin page
<?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>';
@corsonr
corsonr / gist:100f1b1976a43442c58d
Created August 7, 2014 14:57
WooCommerce Product Enquiry: send email to post author
<?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 );
@bavington
bavington / woo-checkout-fields.php
Last active May 25, 2021 09:56
Reorder Checkout Fields in WooCommerce
// 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'];
@RadGH
RadGH / woocommerce-custom-cart-item-data.php
Last active April 27, 2024 17:25
Get and set custom cart item/product information prior to WooCommerce checkout, and carry those valus over to Order Item Metadata.
<?php
// UPDATE: Stefan from Stack Overflow has explained a better way to handle cart item data.
// See http://stackoverflow.com/a/32327810/470480
// ----------------------
/*
Instructions:
@75nineteen
75nineteen / customer-new-account.php
Last active May 2, 2023 18:08
Include email address in new customer email for WooCommerce instead of user login
<?php
/**
* Customer new account email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 1.6.4
*/
// load customer data and user email into email template