در صفحه تسویه حساب یک فیلد مطابق شکل زیر خالی می باشد و همین طور فیلد استان هم اصلا هیچ استانی نشون داده نمیشه. من از
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;}
در موقع خرید محصولا فیزیکی فیلد استان ها مشکلی نداره اما محصولات مجازی چیزی نشون نمیده .و اصلا هم به نظرم نیاز نیست باشه
ممنون میشم دوستان راهنمایی کنند که چطور این دو فیلد را حذف یا اصلاح کنم موقع خرید محصولات مجازی؟
لینک ها تنها برای اعضای سایت قابل نمایش است.
استفاده می کنم تا موقع خرید محصولات مجازی فیلدهای اضافی نشون نده 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;}
در موقع خرید محصولا فیزیکی فیلد استان ها مشکلی نداره اما محصولات مجازی چیزی نشون نمیده .و اصلا هم به نظرم نیاز نیست باشه
ممنون میشم دوستان راهنمایی کنند که چطور این دو فیلد را حذف یا اصلاح کنم موقع خرید محصولات مجازی؟
You must be registered for see images attach
آخرین ویرایش توسط مدیر: