• Hi, I am using WCFM with WordPress. Now I got stuck into 2 things.
    1. My vendor needs weight-based shipping costs outside of his city and wants to give free shipping to his own city. Currently, I can only choose a weight-based shipping method or else zone-based method.
    2. The same vendor wants to give COD at his nearby place only, not for outside. Outside he wants payment gateway.

    To enable or disable the COD by Vendor I used Following Code: Code is wordking, But that does not solve my issues.

    // Payment Gateway Control
    add_filter( ‘woocommerce_available_payment_gateways’, function( $available_gateways ) {
    global $WCFM;
    if( !is_admin() && isset( $available_gateways[‘cod’] ) ) {
    $cod_available = false;
    foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    $cod_available = false;
    $_product = apply_filters( ‘woocommerce_cart_item_product’, $cart_item[‘data’], $cart_item, $cart_item_key );

    if ( $_product && $_product->exists() && $cart_item[‘quantity’] > 0 && apply_filters( ‘woocommerce_checkout_cart_item_visible’, true, $cart_item, $cart_item_key ) ) {
    $vendor_id = $WCFM->wcfm_vendor_support->wcfm_get_vendor_id_from_product( $_product->get_id() );
    if( !$vendor_id || !wcfm_is_vendor( $vendor_id ) ) continue;
    $vendor_data = get_user_meta( $vendor_id, ‘wcfmmp_profile_settings’, true );
    if( !$vendor_data ) $vendor_data = array();
    $is_cod_enabled = isset( $vendor_data[‘payment’][‘wcfm_cod_enabled’] ) ? ‘yes’ : ‘no’ ;
    if( $is_cod_enabled == ‘yes’ ) {
    $cod_available = true;
    }
    }
    }

    // Unset COD
    if( !$cod_available )
    unset( $available_gateways[‘cod’] );
    }

    return $available_gateways;
    }, 200 );

    // Vendor Setting
    add_filter( ‘wcfm_marketplace_settings_fields_billing’, function( $vendor_billing_fileds, $vendor_id ) {
    $vendor_data = get_user_meta( $vendor_id, ‘wcfmmp_profile_settings’, true );
    if( !$vendor_data ) $vendor_data = array();
    $is_cod_enabled = isset( $vendor_data[‘payment’][‘wcfm_cod_enabled’] ) ? ‘yes’ : ‘no’ ;

    $vendor_wcfm_cod_enabled_fileds = array(
    ‘wcfm_cod_enabled’ => array(‘label’ => __(‘COD Enable for Checkout’, ‘wc-frontend-manager’), ‘name’ => ‘payment[wcfm_cod_enabled]’, ‘type’ => ‘checkbox’, ‘class’ => ‘wcfm-checkbox wcfm_ele’, ‘label_class’ => ‘wcfm_title wcfm_ele checkbox_title’, ‘value’ => ‘yes’, ‘dfvalue’ => $is_cod_enabled ),
    );
    $vendor_billing_fileds = array_merge( $vendor_wcfm_cod_enabled_fileds, $vendor_billing_fileds );
    return $vendor_billing_fileds;
    }, 50, 2);

    Any Solution? Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need Shipping and payment issue solution’ is closed to new replies.