با سلام و خداقوت بابت افزونه خیلی خوبتون
افزونه برای من خوب کار می کنه و مشکلی نداره فقط در محصولات مجازی این مشکل وجود داره
من از کد زیر برای مخفی سازی کشور ، ادرس ، کدپستی و شهر موقع خرید تنها محصولات مجازی استفاده می کنم
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );function custom_override_checkout_fields( $fields ) { global $woocommerce; $hasPhysicalProduct = false; if ( ! empty( $woocommerce->cart->cart_contents ) ) { // Cart is not empty, now loop through the cart $cart = $woocommerce->cart->get_cart(); foreach ( $cart as $key => $values ) { $_product = get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] ); if ( ! empty( $_product ) && $_product->exists() && $values['quantity'] > 0 ) { if ($_product->virtual == 'no' && $_product->downloadable == 'no') { $hasPhysicalProduct = true; break; } } } } if ($hasPhysicalProduct == false) { unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); } return $fields;}
همه ی موارد موقعی که در سبد خرید محصول مجازی باشه مخفی میشه حتی شهر اما این فیلد بدون هیچ شهر و استانی وجود داره می خواستم راهنمایی کنید که کد این قسمت چیه
در تصویر می بینید که هیچ استانی در فیلد وجود نداره
در کد بالا بخشی که برای مخفی کردن شهرها هست این کد هستش
unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']);
می خوام این فیلد کدش رو بهم بفرمایید که چه تغییری باید درش بدم تا اون کادر بالایی که عکسش رو فرستادم نشون داده نشه
unset($fields['billing']['billing_city']);
با تشکر فراوان