Get store name at checkout
-
Hi,
I need to hide Cash on Pickup method based on the shop name.
My code looks like this but I can’t get any data from the order inside this hook.
How can I solve this?add_filter( 'woocommerce_available_payment_gateways' , 'change_payment_gateway'); function change_payment_gateway( $gateways ){ $COD = array( "Shop1"=>"yes", "Shop2"=>"no", "Shop3"=>"yes" ); $cartItems = WC()->cart->get_cart(); foreach ( $cartItems as $cartItemKey => $cartItem ) { $vendorId = get_post_field( 'post_author', $cartItem['product_id'] ); } $shopName = dokan()->vendor->get( $vendorId )->get_shop_name(); if(!$vendorId) { return; } if(empty($shopName)) { return; } if( $COD[$shopName] === "no"){ unset( $gateways['cod'] ); } return $gateways; }
Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get store name at checkout’ is closed to new replies.