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 | |
// New order APG SMS just for Multibanco and Bank Transfer | |
add_filter( 'apg_sms_send_message', 'my_apg_sms_send_message', 10, 2 ); | |
function my_apg_sms_send_message( $send, $order ) { | |
$status = is_callable( array( $order, 'get_status' ) ) ? $order->get_status() : $order->status; | |
//New order? (Not the English synthpop band...) | |
if ( $status == 'on-hold' || $status == 'pending' ) { | |
$payment_method = is_callable( array( $order, 'get_payment_method' ) ) ? $order->get_payment_method() : $order->payment_method; //WC >=3.0 or older? | |
switch ($payment_method) { |
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 | |
// Bank Transfer details | |
add_filter('apg_sms_message', 'apg_sms_message_bank_transfer', 999, 2); | |
function apg_sms_message_bank_transfer( $message, $order_id ) { | |
$inst = ''; | |
$order = new WC_Order($order_id); | |
$status = is_callable( array( $order, 'get_status' ) ) ? $order->get_status() : $order->status; //WC >=3.0 or older? | |
//New order? (Not the English synthpop band...) | |
if ( $status == 'on-hold' || $status == 'pending' ) { | |
$payment_method = is_callable( array( $order, 'get_payment_method' ) ) ? $order->get_payment_method() : $order->payment_method; //WC >=3.0 or older? |
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_filter( 'fb_og_image_additional', 'extra_preview_images' ); | |
function extra_preview_images( $fb_image_additional ) { | |
//You could/should use your own logic to decide which images to return. This example only shows you the structure of the array you should return. | |
if ( !is_array( $fb_image_additional ) ) { | |
$fb_image_additional = array(); | |
} | |
$fb_image_additional[] = array( | |
'fb_image' => 'https://domain.com/wp-content/uploads/og_image2.jpg', |
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
//Add as many IBAN / NIB field IDs as you want | |
var ibanFields = [ | |
"LT_BPINet_wt1_block_wtMainContent_CS_ClienteCanais_wt42_block_WebPatterns_wt581_block_wtContent_LT_BPI_Patterns_wtDadosBeneficiarioNacional_block_wtForm_LT_BPI_Patterns_wtRowIBAN_block_wtRow_LT_BPI_Patterns_wtIBAN_block_wtInput_wtTxtIBAN", | |
"LT_BPINet_wt20_block_wtMainContent_CS_Transferencias_wt12_block_wt3_WebPatterns_wt820_block_wtContent_LT_BPI_Patterns_wtfmFomularioDadosTranferencia_block_wtForm_LT_BPI_Patterns_wttxtIBAN_block_wtRow_LT_BPI_Patterns_wt652_block_wtInput_wttxtIBAN2", | |
"LT_BPINet_wt60_block_wtMainContent_CS_Transferencias_wt68_block_WebPatterns_wt273_block_wtContent_LT_BPI_Patterns_wt999_block_wtForm_LT_BPI_Patterns_wt442_block_wtRow_LT_BPI_Patterns_wt55_block_wtInput_wttxtContaIBANDestinatario" | |
]; | |
//Add the event listener | |
for (var i = 0, len = ibanFields.length; i < len; i++) { | |
if ( el=document.getElementById(ibanFields[i]) ) el.addEventListener('paste', cleanIban); |
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
var pagServField1 = "LT_BPINet_wt43_block_wtMainContent_CS_CartoesDebito_wt7_block_WebPatterns_wt122_block_wtContent_LT_BPI_Patterns_wt292_block_wtForm_LT_BPI_Patterns_wt57_block_wtRow_LT_BPI_Patterns_wt691_block_wtInput_wttxtRef1"; | |
var pagServField2 = "LT_BPINet_wt43_block_wtMainContent_CS_CartoesDebito_wt7_block_WebPatterns_wt122_block_wtContent_LT_BPI_Patterns_wt292_block_wtForm_LT_BPI_Patterns_wt57_block_wtRow_LT_BPI_Patterns_wt691_block_wtInput_wttxtRef2"; | |
var pagServField3 = "LT_BPINet_wt43_block_wtMainContent_CS_CartoesDebito_wt7_block_WebPatterns_wt122_block_wtContent_LT_BPI_Patterns_wt292_block_wtForm_LT_BPI_Patterns_wt57_block_wtRow_LT_BPI_Patterns_wt691_block_wtInput_wttxtRef3"; | |
if ( el=document.getElementById(pagServField1) ) el.addEventListener('paste', pasteRef); | |
function pasteRef(e) { | |
e.stopPropagation(); | |
e.preventDefault(); | |
var clipboardData = e.clipboardData || window.clipboardData; |
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 | |
// Disable all products from being purchasable (Yes, that's it...) - Add this to your (child) theme functions.php file | |
add_filter( 'woocommerce_is_purchasable', '__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 | |
add_filter( 'cppw_get_shipping_methods', 'woocommerce_flatrate_percountry_cppw_get_shipping_methods' ); | |
function woocommerce_flatrate_percountry_cppw_get_shipping_methods( $shipping_methods ) { | |
$shipping_methods[] = 'woocommerce_flatrate_percountry'; | |
return $shipping_methods; | |
} |
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 | |
/* WooCommerce prices shown with or without tax depending on client type */ | |
add_filter( 'option_woocommerce_tax_display_shop', 'woocommerce_show_prices_with_or_without_tax' ); | |
add_filter( 'option_woocommerce_tax_display_cart', 'woocommerce_show_prices_with_or_without_tax' ); | |
function woocommerce_show_prices_with_or_without_tax( $option ) { | |
if ( is_user_logged_in() ) { | |
//Client type from user_meta or profile or whatever... | |
//Example: $client_hide_tax = get_user_meta( get_current_user_id(), 'client_type', true ) ? true : false; | |
//Example to create this field on registration: https://gist.github.com/webdados/c8dbbe7ccdea3463312e5b865ad92d92 |
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
/* Add client type field to registration */ | |
add_action( 'woocommerce_register_form_start', 'woocommerce_register_form_start_client_type' ); | |
function woocommerce_register_form_start_client_type() { | |
?> | |
<p class="form-row form-row-wide"> | |
<label for="reg_client_type"><?php _e( 'Client type', 'textdomain' ); ?></label> | |
<select class="" name="client_type" id="client_type"> | |
<option value="person"<?php if ( isset($_POST['client_type']) && $_POST['client_type']=='person' ) echo ' selected="selected"'; ?>><?php _e( 'Person', 'textdomain' ); ?></option> | |
<option value="company"<?php if ( isset($_POST['client_type']) && $_POST['client_type']=='company' ) echo ' selected="selected"'; ?>><?php _e( 'Company', 'textdomain' ); ?></option> | |
</select> |
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 | |
/* | |
If you want the "Facebook Open Graph, Google+ and Twitter Card Tags" WordPress plugin to be able | |
to clear/update the cache of your posts and pages, you'll need to create a facebook app and add | |
it's ID and secret to the URL. | |
1) Go to https://developers.facebook.com/apps/ and create a new app (or choose and existant one, any app will do) | |
2) Copy the App ID and App Secret from your app dashboard | |
3) Add this to your (child-)theme's functions.php file and replace MY_APP_ID and MY_APP_SECRET with your app details |