WCFM Snippet Send Vendor Bank Details to the Customer

Table of Contents

Code Snippet Overview

The WCFM snippet aimed to Send the bank details directly to the customer is great when you want the buyer pays directly to the seller through bank transfer. When you install the WCFM plugin of WCLovers you will see that when a customer makes a purchase, the admin bank details are sent to the customer, but if you want to send just the vender details, use this WCFM snippet.

Result

As you can see, now there is a tab that says Customer Pay option and a text field that can be edit by the store owner so he can put his bank account details. Also, as it is a text field, the store owner can write additional instructions or conditions to the client.

Advertisements
Bank details after the WCFM code snippet implementation.

WCFM Code Snippet

function wcfmmp_vendor_customer_pay_option( $vendor_id ) {
	global $WCFM, $WCFMmp;
	$active_order_payment_methods      = get_wcfm_marketplace_disallow_order_payment_methods();
	
	$wcfm_preferred_customer_payment   = get_user_meta( $vendor_id, 'wcfm_preferred_customer_payment', true );
	$wcfm_customer_payment_options     = get_user_meta( $vendor_id, 'wcfm_customer_payment_options', true );
	
	if( did_action( 'wcfm_vendor_settings_after_shipping' ) ) {
		?>
		<!-- collapsible -->
		<div class="page_collapsible" id="wcfm_settings_form_min_order_amount_head">
			<label class="wcfmfa fa-cart-plus"></label>
			<?php _e('Customer Pay Option', 'wc-frontend-manager'); ?><span></span>
		</div>
		<div class="wcfm-container">
			<div id="wcfm_settings_form_vendor_invoice_expander" class="wcfm-content">
			<?php
	} else {
		?>
		<div class="wcfm_clearfix"></div>
		<div class="wcfm_vendor_settings_heading"><h2><?php _e('Customer Pay Option', 'wc-frontend-manager'); ?></h2></div>
		<div class="wcfm_clearfix"></div>
		<div class="store_address">
		<?php
	}
	?>
			<?php
			$WCFM->wcfm_fields->wcfm_generate_form_field(  array(
				                                                    "wcfm_preferred_customer_payment" => array('label' => __('Preferred Payment Method', 'wc-frontend-manager'), 'type' => 'select', 'class' => 'wcfm-select wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele', 'options' => $active_order_payment_methods, 'value' => $wcfm_preferred_customer_payment ),
																														"wcfm_customer_payment_options"   => array('label' => __('Payment Details', 'wc-frontend-manager'), 'type' => 'textarea', 'class' => 'wcfm-textarea wcfm_ele wcfm_full_ele', 'label_class' => 'wcfm_title wcfm_ele wcfm_full_ele_title', 'value' => $wcfm_customer_payment_options ),
																														) );
	    ?>
		</div>
	<?php if( did_action( 'wcfm_vendor_settings_after_shipping' ) ) { ?>
	</div>
  <?php } ?>
	<div class="wcfm_clearfix"></div>
	<!-- end collapsible -->
	<?php
}
add_action( 'wcfm_vendor_settings_after_shipping', 'wcfmmp_vendor_customer_pay_option', 500 );
add_action( 'wcfmmp_admin_wcfm_vendor_commission_payment_settings_after', 'wcfmmp_vendor_customer_pay_option', 500 );

add_action( 'wcfm_vendor_settings_update', function( $vendor_id, $wcfm_settings_form ) {
	global $WCFM, $WCFMmp;
	if( isset( $wcfm_settings_form['wcfm_preferred_customer_payment'] ) ) {
		$wcfm_preferred_customer_payment = $wcfm_settings_form['wcfm_preferred_customer_payment'];
		update_user_meta( $vendor_id, 'wcfm_preferred_customer_payment',  $wcfm_preferred_customer_payment );
	}
	if( isset( $wcfm_settings_form['wcfm_customer_payment_options'] ) ) {
		$wcfm_customer_payment_options = $wcfm_settings_form['wcfm_customer_payment_options'];
		update_user_meta( $vendor_id, 'wcfm_customer_payment_options',  $wcfm_customer_payment_options );
	}
}, 500, 2 );

function wcfmmp_vendor_order_customer_payment_options( $order ) {
	global $WCFM, $WCFMmp;
	if( function_exists('is_wcfm_page') && is_wcfm_page() ) return;
	echo "<br /><br />";
	echo "<h2 style='font-size: 18px; color: #17a2b8; line-height: 20px;margin-top: 6px;margin-bottom: 10px;padding: 0px;text-decoration: underline;'>" . __( 'Payment Details:', 'wc-frontend-manager-ultimate' ) . "</h2>";
	echo "<table width='100%' style='width:100%;'><tbody>";
	$line_items   = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
	$line_items   = apply_filters( 'wcfm_valid_line_items', $line_items, $order->get_id() );
	$processed_vendor_ids = array();
	foreach ( $line_items as $item_id => $item ) {
		$product_id = $item->get_product_id();
		$vendor_id           = wcfm_get_vendor_id_by_post( $product_id );
		if( !$vendor_id || !wcfm_is_vendor( $vendor_id ) ) continue;
		if( ( apply_filters( 'wcfm_is_allow_order_item_policies_by_vendor', true ) || !apply_filters( 'wcfm_is_show_marketplace_itemwise_orders', true ) ) && in_array( $vendor_id, $processed_vendor_ids ) ) continue;
		$processed_vendor_ids[$vendor_id] = $vendor_id;
		if( wcfm_is_vendor() && ( $vendor_id != $WCFMmp->vendor_id ) ) continue;
		$wcfm_customer_payment_options     = get_user_meta( $vendor_id, 'wcfm_customer_payment_options', true );
		if( !$wcfm_customer_payment_options ) continue;
		$wcfm_preferred_customer_payment   = get_user_meta( $vendor_id, 'wcfm_preferred_customer_payment', true );
		if( $wcfm_preferred_customer_payment && ( $wcfm_preferred_customer_payment != $order->get_payment_method() ) ) continue;
		$store_name          = wcfm_get_vendor_store_name( $vendor_id );
		?>
		<tr>
			<td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;font-weight:600;">
			  <?php 
			  if( apply_filters( 'wcfm_is_allow_order_item_policies_by_vendor', true ) || !apply_filters( 'wcfm_is_show_marketplace_itemwise_orders', true ) ) {
			  	echo $store_name . ' ';
			  	$gross_sales = $WCFM->wcfm_vendor_support->wcfm_get_gross_sales_by_vendor( $vendor_id, '', false, $order->get_id() );
			  	echo "<br />Payable Amount: " . wc_price( $gross_sales );
			  } else {
			  	echo get_the_title( $product_id ) . ' ('. $store_name .') ';
			  }
			  ?>
			</td>
			<td colspan="5" style="background-color: #f8f8f8;padding: 1em;"><?php echo wpautop($wcfm_customer_payment_options); ?></td>
		</tr>
		<?php
	}
	echo "</tbody></table>";
	echo "<br /><br /><br /><br />";
}
add_action( 'woocommerce_order_details_after_order_table', 'wcfmmp_vendor_order_customer_payment_options', 50 );
add_action( 'woocommerce_email_order_meta', 'wcfmmp_vendor_order_customer_payment_options', 50 );

add_action( 'wcfm_store_invoice_vendor_info_after', function( $vendor_id, $order_id, $order, $document ) {
	$wcfm_customer_payment_options     = get_user_meta( $vendor_id, 'wcfm_customer_payment_options', true );
	if( $wcfm_customer_payment_options ) {
		$wcfm_preferred_customer_payment   = get_user_meta( $vendor_id, 'wcfm_preferred_customer_payment', true );
		if( $wcfm_preferred_customer_payment && ( $wcfm_preferred_customer_payment == $order->get_payment_method() ) ) {
			echo '<br /><div class="vendor-shop-phone"><b>Payment Options -</b><br />' . wpautop($wcfm_customer_payment_options) . '</div><br />';
		}
	}
}, 50, 4 );
add_filter( 'wcfm_is_allow_wc_default_email_customer_details', '__return_true' );
add_filter( 'wcfm_is_show_marketplace_itemwise_orders', '__return_false' );

Implementation

  1. Copy the code:
  2. Add a new Code snippet in the Code Snippets plugin
  3. Paste the code snippet.
  4. Activate it.

Note: Is important that in Woocommerce > Settings > Payments > Bank Transfer you erase your bank account otherwise the invoice that the buyer receives will also include your Bank Account information.

More WCFM Code Snippets related:

All Post Category:

Check out our categories: Android Update, Elementor, flutter, Guide, Game, Plugin, Theme, webmaster, SEO

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

My Orders

My Downloads

My Booked Services

My Subscriptions