Skip to content

Instantly share code, notes, and snippets.

View iMazed's full-sized avatar

Ines iMazed

View GitHub Profile
@iMazed
iMazed / functions.php
Last active August 29, 2015 14:15 — forked from kloon/functions.php
WooCommerce: add confirm password field on register form
<?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' ) );
}
// Add to functions.php if you want a redirect to happen when the store is closed.
// Comment out when store needs to open again
add_action('template_redirect','store_closed');
function store_closed(){
if (!is_admin() && is_woocommerce()){
wp_redirect('/store-closed/'); // Change store-closed to permalink you'd like to use
exit;
}
}
@iMazed
iMazed / gist:86dd09dc6860f524e319
Last active August 29, 2015 14:20
Make Peter's Login Redirect work with the Jobify theme
/* Add to your functions.php file */
add_filter( 'jobify_registeration_redirect', array( 'rulRedirectPostRegistration', 'post_registration_wrapper' ), 10, 1 );
<?php
/*
Plugin Name: Primux Mailchimp
Plugin URI: http://primux.dk/
Description: Add new users to a Mailchimp list
Version: 1.0
Author: Primux Media
Author URI: http://primux.dk/
*/
@iMazed
iMazed / suffix.php
Created July 26, 2016 10:41
Add suffix to WooCommerce product price
add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );
function custom_price_suffix( $price, $product ){
$price = $price . ' +VAT';
return apply_filters( 'woocommerce_get_price', $price );
}
@iMazed
iMazed / gist:82f5aa0a53524139ed1d8b64fced6994
Created October 1, 2016 13:17
Change WooCommerce stock email recipient
add_filter('woocommerce_email_recipient_backorder', 'wc_change_admin_backorder_email_recipient', 1, 2);
function wc_change_admin_backorder_email_recipient( $recipient, $order ) {
global $woocommerce;
$recipient = "shop-manager-email@yourdomain.com"; // change this value to the appropriate email!
return $recipient;
}
@iMazed
iMazed / woo-surcharge.functions.php
Last active October 14, 2016 12:32
Add a surcharge to your WooCommerce cart/checkout
<?php
/**
* Add a 3% surcharge to your cart / checkout
* change the $percentage to set the surcharge to a value to suit
*/
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
@iMazed
iMazed / ppc-cpt.php
Created January 29, 2017 17:26
Make Pre-Publish Post Checklist work with Custom Post Types
/**
* Make Pre-Publish Post Checklist work with Custom Post Types
* Add to your functions.php file
*/
function my_add_meta_boxes() {
add_meta_box(
'pc-meta-box',
'Pre-Publish Post Checklist',
'pc_create_meta_box_callback',
'YOUR_CPT', /* Change this your Custom Post Type ID */
@iMazed
iMazed / changehover.css
Last active June 8, 2017 09:25
Change hover button color
.woocommerce-message a.button.wc-forward:hover {
color: #222 !important; /* change this color code! */
}
.woocommerce input.button, .woocommerce input.button:hover {
color: #333 !important;
}
@iMazed
iMazed / move-eu-vat-field.css
Created November 20, 2017 09:48
Move EU VAT Number field
#woocommerce_eu_vat_number {
position: absolute;
top: 230px;
width: 100%;
}
#billing_country_field {
margin-top: 6em;
}