رفتن به مطلب

مشکل در کد مربوط به حذف یک روش حمل و نقل برای یک دسته از محصولات


پست های پیشنهاد شده

hh
اbegin   remove shipping method from some product category */
/***************************************************************/
/*
add_filter( 'woocommerce_package_rates', 'specific_products_shipping_methods', 10, 2 );
function specific_products_shipping_methods( $rates, $package ) {
    // HERE set the product category in the array (ID, slug or name)
    $terms = array( 'np' ); 
    $taxonomy = 'product_tag'; 

    // HERE set the shipping methods to be removed (like "fat_rate:5")
    $method_instances_ids = array(11);  

    $found = false;

    // Loop through cart items checking for defined product IDs
    foreach( $package['contents'] as $cart_item ) {
        if ( has_term( $terms, $taxonomy, $cart_item['product_id'] ) ){
            $found = true;
            break;
        }
    }

    if ( ! $found ) return $rates; // If not found we exit

    // Loop through your active shipping methods
    foreach( $rates as $rate_id => $rate ) {
        // Remove all other shipping methods other than your defined shipping method
        if ( in_array( $rate_id, $method_instances_ids ) ){
            unset( $rates[$rate_id] );
        }
    }    

    return $rates;
}
*/
/** End   remove shipping method from some product category */
/*

سلام 

من برای اینکه بتونم ازیه دسته از محصولات تو ووکامرس بعضی روشهای حمل و نقل رو حذف کنم از کد بالا استفاده کردم و تو functions اوردمش 

اما کار نمی کنه . کسی می تونه کمک کنه . 

شماره کتگوری رو از صفحه دسته بندی ها دراوردم 

و instance id روش حمل ونقل رو هم از تو صفحه حمل و نقل در اوردم

 
  •  
  •  
لینک به ارسال
  • asadiy4n این مورد را قفل کرد موضوع
مهمان
این موضوع برای عدم ارسال قفل گردیده است.
×
×
  • اضافه کردن...