This file contains 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
/** | |
* Use WC 2.0 variable price format, now include sale price strikeout | |
* | |
* @param string $price | |
* @param object $product | |
* @return string | |
*/ | |
function wc_wc20_variation_price_format( $price, $product ) { | |
// Main Price | |
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); |
This file contains 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 R xx.xx per KG | |
add_action( 'woocommerce_price_html', 'wc_custom_price', 10, 2 ); | |
function wc_custom_price( $price, $product ) { | |
return sprintf( __( '%s per KG', 'woocommerce' ), woocommerce_price( $product->get_price() ) ); | |
} | |
?> |
This file contains 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 | |
// Show trailing zeros on prices, default is to hide it. | |
add_filter( 'woocommerce_price_trim_zeros', 'wc_hide_trailing_zeros', 10, 1 ); | |
function wc_hide_trailing_zeros( $trim ) { | |
// set to false to show trailing zeros | |
return false; | |
} | |
?> |
This file contains 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 | |
// Place in your theme's functions.php file | |
// Revert grouped product prices to WooCommerce 2.0 format | |
add_filter( 'woocommerce_grouped_price_html', 'wc_wc20_grouped_price_format', 10, 2 ); | |
function wc_wc20_grouped_price_format( $price, $product ) { | |
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' ); | |
$child_prices = array(); | |
foreach ( $product->get_children() as $child_id ) { | |
$child_prices[] = get_post_meta( $child_id, '_price', true ); |
This file contains 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 | |
// place the following code in your theme's functions.php file | |
// Add a second password field to the checkout page. | |
add_action( 'woocommerce_checkout_init', 'wc_add_confirm_password_checkout', 10, 1 ); | |
function wc_add_confirm_password_checkout( $checkout ) { | |
if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) { | |
$checkout->checkout_fields['account']['account_password2'] = array( | |
'type' => 'password', | |
'label' => __( 'Confirm password', 'woocommerce' ), | |
'required' => true, |
This file contains 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 the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts. | |
add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3); | |
function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { | |
global $woocommerce; | |
extract( $_POST ); | |
if ( strcmp( $password, $password2 ) !== 0 ) { | |
return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'woocommerce' ) ); | |
} |
This file contains 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
/* 1. Update Pending Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-pending' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'pending%'; |
This file contains 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 | |
function wc_pdf_watermark_extend_template_tags( $parsed_text, $unparsed_text, $order, $product ) { | |
// Look for {product_title} in text and replace it with the product title | |
$parsed_text = str_replace( '{product_title}', $product->get_title(), $parsed_text ); | |
return $parsed_text; | |
} | |
add_filter( 'woocommerce_pdf_watermark_parse_template_tags', 'wc_pdf_watermark_extend_template_tags' ); |
This file contains 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 | |
function wc_pdf_watermark_change_pdf_password( $order_id, $product_id ) { | |
// Use the order number for the password instead of the billing email | |
$order = wc_get_order( $order_id ); | |
return $order->get_order_number(); | |
} | |
add_filter( 'woocommerce_pdf_watermark_file_password', 'wc_pdf_watermark_change_pdf_password' ); |
This file contains 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 | |
/** | |
* Do not allow account creation with temp email addresses | |
* @param Object $validation_errors | |
* @param string $username | |
* @param string $email | |
* @return WP_Error | |
*/ | |
function do_not_allow_temp_email_addresses( $validation_errors, $username, $email ) { | |
$prohibitied_domains = array( |