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_action( 'template_redirect', 'redirect_if_not_logged_in' ); | |
function redirect_if_not_logged_in() { | |
if ( ! is_user_logged_in() ) wp_redirect( wp_login_url( $_SERVER['REQUEST_URI'] ) ); | |
} |
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 this to you (child-)theme functions.php file, on a (mu-)plugin or with a plugin like Code Snippets https://wordpress.org/plugins/code-snippets/ */ | |
/* This only works with the classic checkout */ | |
add_filter( 'shop_as_client_pro_customer_data', 'my_shop_as_client_pro_customer_data', 10, 3 ); | |
function my_shop_as_client_pro_customer_data( $data, $customer = null, $order = null ) { | |
//Are we getting a "customer" object? | |
if ( $customer ) { | |
//Custom checkout field with id "billing_xpto" |
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_filter( 'woocommerce_get_availability', 'my_woocommerce_get_availability' ); | |
function my_woocommerce_get_availability( $availability ) { | |
if ( $availability['class'] === 'available-on-backorder' ) { | |
$availability['availability'] = 'Your text here'; | |
// or, if you have localized strings | |
// $availability['availability'] = __( 'Your text here', 'your-textdomain' ); | |
} |
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_filter( 'woocommerce_display_product_attributes', 'extra_product_information', 10, 2 ); | |
function extra_product_information( $product_attributes, $product ) { | |
$the_value = $product->get_meta( '_any_custom_field' ); | |
if ( trim( $the_value ) != '' ) { | |
$product_attributes['any_custom_field'] = array( | |
'label' => 'Your label', | |
'value' => $the_value | |
); |
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 each filter to your (child-)theme functions.php file if you want to change any configuration */ | |
//Separator between options (default: new line) | |
add_filter( 'invoicexpress_woocommerce_eo_separator', function( $string ) { | |
return PHP_EOL; | |
} ); | |
//Start before each option (default: '- ') | |
add_filter( 'invoicexpress_woocommerce_eo_start', function( $string ) { |
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_filter( 'portugal_ctt_tracking_email_info', 'my_portugal_ctt_tracking_email_info', 10, 4 ); | |
function my_portugal_ctt_tracking_email_info( $html, $order_object, $sent_to_admin, $plain_text ) { | |
//Do whatever you want with the HTML | |
//You can get the tracking code with $order_object->get_meta( '_ctt_tracking_code' ) | |
return $html; | |
} |
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_filter( 'shop_as_client_allow_checkout', function() { | |
$user = wp_get_current_user(); | |
return in_array( 'whatver_role', (array) $user->roles ); | |
} ); |
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_filter( 'woocommerce_checkout_fields', 'my_woocommerce_checkout_fields', 60 ); | |
function my_woocommerce_checkout_fields( $fields ) { | |
if ( isset( $fields['billing']['billing_VAT_code'] ) ) { | |
$fields['billing']['billing_VAT_code']['class'] = array( 'form-row-first' ); //Or form-row-last | |
$fields['billing']['billing_VAT_code']['clear'] = true; //Or false if we use form-row-last | |
$fields['billing']['billing_VAT_code']['priority'] = 120; //120 is the default position, change this to move it up or down on the form | |
} | |
return $fields; | |
} |
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 to your (child-)theme functions.php file | |
add_filter( 'woocommerce_portugal_address_format_include_state', '__return_true' ); |