Skip to content

Instantly share code, notes, and snippets.

@BFTrick
BFTrick / force-display-country-address.php
Last active August 7, 2017 09:04
Force WooCommerce to display the country in the address even when it's the same country as the store base location. Also posted here: http://wordpress.stackexchange.com/questions/110167/woocommerce-force-display-of-base-country-order-addresses/110168#110168
<?php
add_filter( 'woocommerce_formatted_address_force_country_display', '__return_true' );
@webaware
webaware / add-to-cart.php
Last active October 9, 2024 00:33 — forked from mikejolley/functions.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme
@etiennetremel
etiennetremel / content-single-product.php
Last active November 13, 2024 17:23
WooCommerce Upsells Upsells as checkbox. When product is deleted from the cart, upsells are also deleted.
<?php
/**
* The template for displaying product content in the single-product.php template
*
* Override this template by copying it to yourtheme/woocommerce/content-single-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
@landru247
landru247 / WordPress: Contact Form 7 - validation.
Created September 9, 2013 19:46
WordPress: Contact Form 7 - extend validation for things like phone numbers, zip codes, etc....
// Link to project page
// http://code-tricks.com/contact-form-7-custom-validation-in-wordpress/
//Available Names for text field with this file
date1 – Compare date1 (date2 should be bigger than date1)
date2 – Compare date2 (date2 should be bigger than date1)
url – validate URL
emailAddress – validate email address
@webaware
webaware / debug-log-not-strict.php
Last active December 23, 2024 02:31
Turn on WordPress' WP_DEBUG_LOG but without E_STRICT. Accompanying blog post: http://snippets.webaware.com.au/snippets/wordpress-wp_debug_log-without-e_strict/
<?php
/*
Plugin Name: Debug Log Not Strict
Plugin URI: https://gist.github.com/webaware/6520892
Description: Turn on WP_DEBUG_LOG but without E_STRICT
Version: 1.4.0
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
@BFTrick
BFTrick / non-hierachical-category-permalinks.php
Created September 20, 2013 15:36
Make the product category permalinks non hierarchical. So instead of `shop/clothing/t-shirt/` we'll see `shop/t-shirt/`
@BFTrick
BFTrick / gettext-filter-multiple.php
Last active March 30, 2023 07:18
Use the gettext WordPress filter to change any translatable string.
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sale!' :
$translated_text = __( 'Clearance!', 'woocommerce' );
@vividvilla
vividvilla / sale-flash.php
Last active October 18, 2018 10:10
Display Discount/Offer percentage in WooCommerce
<?php
/**
* Product loop sale flash
*
* @author Vivek R @ WPSTuffs.com
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*valid email checking*/
<?php
if(isset($_POST['email'])){
$email = $_POST['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo '<p>This is a valid email.<p>';
}else{
echo '<p>This is an invalid email.</p>';
}
}
@woogist
woogist / gist:7302382
Created November 4, 2013 13:24
WooCommerce - rename additional information tab
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
}