WC Lovers

WooCommerce Frontend Manager - Multivendor marketplace vendor dashboard

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • abbasi.aye
    Participant

    Thanks a lot of the help

    In order to achieve the above target, we have two snippets,
    1. Snippet-1 to add a drop-down menu in the checkout page to obtain the customer’s special sub-region.
    2. Snippet-2 to fetch the selected value from the previously added drop-down menu (say store it in $user_selected_field), then use it and also using the stores in the cart to modify the shipping rate.

    Can you help me finding a way to get the selected value of selected value from drop down from the checkout page class?

    =====================================================
    2. Snippet-2 Looks like:

    define( ‘WP_DEBUG’, true );

    add_filter( ‘woocommerce_shipping_method_add_rate_args’, ‘AA_shipping_extra_per_product’, 100, 2 );
    function AA_shipping_extra_per_product( $args, $shipping_method ) {
    /* Interacting with dropdown menue code
    */
    $arr_co_fields = wc()->checkout()->get_checkout_fields();//($fieldset = ‘shipping’);
    $user_selected_field = $arr_co_fields[‘billing’][‘billing_city’];//$_POST[$arr_co_fields[‘billing’][‘billing_city’]];
    //$user_selected_field = $_POST[‘dropdown’]; // I’m not sure to read selected value by customer from drop-down menu

    print_r($user_selected_field);

    /* cart info
    */
    $items = wc()->cart->get_cart();
    foreach ( $items as $item => $values ) {
    $product = wc_get_product( $values[‘data’]->get_id() );
    $vendor_id = wcfm_get_vendor_id_by_post( $product->get_id() );
    if ( $vendor_id ) {
    $store_user = wcfmmp_get_store( $vendor_id );
    $shop_name = $store_user->get_shop_name();
    $url = $store_user->get_shop_url();
    $address = $store_user->get_address();

    }
    }

    // decision on extra shipping rate
    $extra_ship = 0;
    if ($vendor_id == 2 && $user_selected_field =2){
    $shippnig_zone = 2
    $extra_ship +=20;
    } elseif($vendor_id == 3 && $user_selected_field =3){
    $shippnig_zone = 3
    $extra_ship +=40;
    }
    $args[‘cost’] = $extra_ship + 1;
    return $args;
    }

Viewing 1 post (of 1 total)