Skip to content

Instantly share code, notes, and snippets.

Marco Almeida webdados

Block or report user

Report or block webdados

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@webdados
webdados / shop_as_client_pro_customer_data.php
Last active Dec 9, 2019
How to add custom fields to the Shop as Client PRO add-on ajax call
View shop_as_client_pro_customer_data.php
<?php
/* Add this to you (child-)theme functions.php file */
add_filter( 'shop_as_client_pro_customer_data', 'my_shop_as_client_pro_customer_data', 10, 2 );
function my_shop_as_client_pro_customer_data( $data, $customer ) {
//Custom field billing_xpto
$data['billing']['xpto'] = $customer->get_meta( 'billing_xpto' );
//Custom field shipping_xpto
$data['shipping']['xpto'] = $customer->get_meta( 'shipping_xpto' );
@webdados
webdados / woocommerce_get_availability.php
Last active Nov 21, 2019
Change "available on backorder" WooCommerce text
View woocommerce_get_availability.php
<?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';
}
return $availability;
}
@webdados
webdados / woocommerce_display_product_attributes.php
Created Nov 11, 2019
Using woocommerce_display_product_attributes
View woocommerce_display_product_attributes.php
<?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
);
View woo-billing-with-invoicexpress-extraoptions.php
<?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 ) {
@webdados
webdados / portugal_ctt_tracking_email_info.php
Created Sep 11, 2019
portugal_ctt_tracking_email_info
View portugal_ctt_tracking_email_info.php
<?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;
}
@webdados
webdados / shop_as_client_allow_checkout.php
Created Jul 18, 2019
Shop as Client - Allow other user roles to use the functionality (Shop managers and Administrators already have the ability to do so)
View shop_as_client_allow_checkout.php
<?php
add_filter( 'shop_as_client_allow_checkout', function() {
return current_user_can( 'whatever_role' );
} );
@webdados
webdados / woocommerce_checkout_fields.php
Created Jul 8, 2019
Manipulate VAT field position on Invoicing with InoiceXpress for WooCommerce
View woocommerce_checkout_fields.php
<?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;
}
@webdados
webdados / woocommerce_portugal_address_format_include_state.php
Created Jun 3, 2019
Add "distrito" to the Portuguese address format while using the "Portugal States (Distritos) for WooCommerce" plugin
View woocommerce_portugal_address_format_include_state.php
<?php
//Add to your (child-)theme functions.php file
add_filter( 'woocommerce_portugal_address_format_include_state', '__return_true' );
@webdados
webdados / invoicexpress_woocommerce_data_obs_payment_method.php
Last active May 14, 2019
Payment method on InvoiceXpress document observations
View invoicexpress_woocommerce_data_obs_payment_method.php
<?php
// This code snippet is to be used with the "Invoicing with InvoiceXpress for WooCommerce" plugin - https://invoicexpress-woocommerce.com/
$types = array(
'invoice',
'simplified_invoice',
'invoice_receipt',
'credit_note',
'quote',
@webdados
webdados / shop_as_client_default_shop_as_client.php
Last active Apr 25, 2019
"no" as default for Shop as client on "Shop as client" plugin
View shop_as_client_default_shop_as_client.php
<?php
add_filter( 'shop_as_client_default_shop_as_client', function( $option ) {
return 'no';
});
You can’t perform that action at this time.