$f ) { if ( ! in_array( $key, $keep, true ) ) { unset( $fields['billing'][ $key ] ); } } // Država fiksno BiH, sakriveno $fields['billing']['billing_country']['type'] = 'hidden'; $fields['billing']['billing_country']['default'] = 'BA'; $fields['billing']['billing_phone']['required'] = true; $fields['billing']['billing_first_name']['priority'] = 10; $fields['billing']['billing_last_name']['priority'] = 20; $fields['billing']['billing_address_1']['priority'] = 30; $fields['billing']['billing_city']['priority'] = 40; $fields['billing']['billing_phone']['priority'] = 50; unset( $fields['order']['order_comments'], $fields['shipping'] ); return $fields; }, 9999 ); add_filter( 'default_checkout_billing_country', fn() => 'BA' ); add_filter( 'woocommerce_enable_order_notes_field', '__return_false' ); add_filter( 'woocommerce_get_country_locale', function ( $locale ) { $locale['BA']['postcode'] = array( 'required' => false, 'hidden' => true ); $locale['BA']['state'] = array( 'required' => false, 'hidden' => true ); return $locale; } ); // 2) Bez korpe: dugme vodi pravo na plaćanje, uvijek samo jedan proizvod add_filter( 'woocommerce_add_to_cart_validation', function ( $passed ) { if ( WC()->cart ) { WC()->cart->empty_cart(); } return $passed; }, 1 ); add_filter( 'woocommerce_add_to_cart_redirect', fn() => wc_get_checkout_url() ); add_filter( 'wc_add_to_cart_message_html', '__return_empty_string' ); add_filter( 'woocommerce_product_single_add_to_cart_text', fn() => 'Naruči odmah' ); add_filter( 'woocommerce_product_add_to_cart_text', fn( $t, $p = null ) => ( $p && $p->is_purchasable() && $p->is_in_stock() ) ? 'Naruči odmah' : $t, 10, 2 );
Idi na sadržaj