Skip to content

Instantly share code, notes, and snippets.

View gaiqus's full-sized avatar

Bartosz Gajewski gaiqus

  • Poznań
View GitHub Profile
@gaiqus
gaiqus / flexible_shipping_free_shipping_notice_text_button_label-delete
Created September 26, 2022 08:34
flexible_shipping_free_shipping_notice_text_button_label - delete
add_filter( 'flexible_shipping_free_shipping_notice_text_button_label', '__return_empty_string' );
@gaiqus
gaiqus / flexible_shipping_free_shipping_notice_text_button_label
Created September 26, 2022 08:32
flexible_shipping_free_shipping_notice_text_button_label
add_filter( 'flexible_shipping_free_shipping_notice_text_button_label', function () {
return 'Button Label';
} );
@gaiqus
gaiqus / flexible_shipping_free_shipping_notice_text_message
Created September 26, 2022 08:29
flexible_shipping_free_shipping_notice_text_message
add_filter( 'flexible_shipping_free_shipping_notice_text_message', function ( $message, $amount ) {
return 'Message Example';
}, 10, 2 );
add_filter( 'woocommerce_states', 'fs_add_uae_emirates' );
function fs_add_uae_emirates( $states ) {
$states['AE'] = array(
'AZ' => __( 'Abu Dhabi', 'woocommerce' ),
'AJ' => __( 'Ajman', 'woocommerce' ),
'FU' => __( 'Fujairah', 'woocommerce' ),
'SH' => __( 'Sharjah', 'woocommerce' ),
'DU' => __( 'Dubai', 'woocommerce' ),
'RK' => __( 'Ras Al Khaimah', 'woocommerce' ),
@gaiqus
gaiqus / WPDeskNoShippingMessage
Created November 10, 2020 14:13
Change the “No Shipping methods available” Message in WooCommerce
class WPDeskNoShippingMessage {
/**
* Register hooks.
*/
public function add_hooks() {
add_filter( 'woocommerce_no_shipping_available_html', [ $this, 'change_message' ] );
add_filter( 'woocommerce_cart_no_shipping_available_html', [ $this, 'change_message' ] );
}
/**
add_filter( 'flexible_shipping_free_shipping_notice_text', 'wpdesk_flexible_shipping_free_shipping_notice_text', 10, 2 );
function wpdesk_flexible_shipping_free_shipping_notice_text( $notice_text, $amount ) {
return sprintf( 'You only need %1$s more to get free shipping!', wc_price( $amount ) );
}
add_filter( 'flexible_shipping_free_shipping_notice_text', 'wpdesk_flexible_shipping_free_shipping_notice_text', 10, 2 );
function wpdesk_flexible_shipping_free_shipping_notice_text( $notice_text, $amount ) {
return sprintf( 'Dodaj do koszyka produkty za łączną kwotę %1$s , aby uzyskać darmową wysyłkę!', wc_price( $amount ) );
}
/**
* Can validate field by comparing value with other field.
*/
class WPDesk_FCF_Validation_Confirm_Field {
/**
* Field to compare with validated field.
*
* @var string
*/
private $field_to_compare;
/**
* Return TRUE if supplied tax ID is valid for supplied country.
*
* @param string $id Taxation ID, e.g. ATU99999999 for Austria.
* @param string $customer_country Country code.
*
* @return bool
*/
function is_eu_vat_number_valid( $id, $customer_country ) {
$id = strtoupper( $id );
@gaiqus
gaiqus / functions.php
Created August 17, 2019 14:26
Set max weight in WooCommerce orders
add_action('woocommerce_check_cart_items','check_cart_weight');
function check_cart_weight(){
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
if( $weight > 20 ){
wc_add_notice( sprintf( __( 'You have %sKg weight and we allow only 20Kg of weight per order.', 'woocommerce' ), $weight ), 'error' );
}
}