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 | |
$states = [ | |
'AC' => 'Acre', | |
'AL' => 'Alagoas', | |
'AP' => 'Amapá', | |
'AM' => 'Amazonas', | |
'BA' => 'Bahia', | |
'CE' => 'Ceará', | |
'DF' => 'Distrito Federal', |
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
add_filter( 'woocommerce_package_rates', 'lpb_change_correios_shipping_response_label', 10, 2 ); | |
function lpb_change_correios_shipping_response_label ( $rates, $package ) { | |
foreach ( $rates as $rate) { | |
if ( false !== strpos($rate->id, 'correios') ) { | |
$rate->label = str_replace( 'Entrega em', 'Entrega em até', $rate->label ); | |
} | |
} | |
return $rates; | |
} |
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
add_filter( 'woocommerce_shipping_calculator_enable_city', '__return_false' ); |
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
function renderTemplate(template, data) { | |
var result = template; | |
for (var key in data) { | |
if (data.hasOwnProperty(key)) { | |
var regex = new RegExp('{{\\s*' + key + '\\s*}}', 'g'); | |
result = result.replace(regex, data[key]); | |
} | |
} | |
return result; | |
} |
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_catalog_orderby', function ( $filters ) { | |
unset( $filters['price'] ); | |
unset( $filters['price-desc'] ); | |
return $filters; | |
} ); |
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
add_action( 'after_setup_theme', 'lpb_remove_admin_bar' ); | |
function lpb_remove_admin_bar () { | |
if ( !current_user_can( 'administrator' ) && ! is_admin () ) { | |
show_admin_bar(false); | |
} | |
} |
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_package_rates', 'custom_correios_free_shipping', 10, 2 ); | |
function custom_correios_free_shipping ( $rates, $package ) { | |
$free_shipping_amount = 350; | |
$cart_total = WC()->cart->subtotal; | |
if ( $cart_total >= $free_shipping_amount ) { | |
foreach ( $rates as $rate) { | |
if ( 'correios-pac' === $rate->method_id && $rate->cost > 0 ) { |
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' , 'lpb_override_checkout_fields', 20 ); | |
function lpb_override_checkout_fields ( $fields ) { | |
// remove o campo "sexo" | |
unset( $fields['billing']['billing_sex'] ); | |
// remove obrigatoriedade do campo "data de nascimento" | |
if ( isset( $fields['billing']['billing_birthdate'] ) ) { | |
$fields['billing']['billing_birthdate']['required'] = false; |
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 | |
$email_subject = 'Subject'; | |
$email_to = '[email protected], [email protected]'; | |
$title = 'Custom email'; | |
$message = 'Hello world!'; | |
WC()->mailer()->send( | |
$email_to, |
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 | |
/* | |
english: put the below code in your functions.php | |
português: coloque o código abaixo no seu functions.php ou siga este guia: https://bit.ly/2Nn0SvD | |
*/ | |
add_filter( 'wc_force_auth_message', function ( $message ) { | |
return 'your new message/sua nova mensagem'; | |
} ); |