Vendor Bank Details in Purchase Confirmation

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!

  • This topic has 6 replies, 3 voices, and was last updated 4 years ago by klub.
Viewing 6 reply threads
  • Author
    Posts
    • #112808
      alexdezi
      Participant

      Hi! I would like to send the vendors bank details to the buyer, so 100% of the payment is going directly to the vendor.
      I have seen this code snippet in another plugin which adds the provided vendor bank details in the purchase confirmation and email confirmations.
      Can this be done with WCFM?

      This is the code – I also tested it and it works fine:
      https://wordpress.org/support/topic/shopping-directly-from-the-vendor-and-excluding-the-commission/

      Thank you!

    • #114778
      WCFM Forum
      Keymaster

      Hi,

      Add this code to your site for the purpose –

      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' );

      Add this code to your child theme’s functions.php
      In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

      Now, vendor has to set there preferred customer payment method ans details from their setting -> Customer Pay Options tab – https://ibb.co/NSyWRty

      Thank You

    • #115181
      klub
      Participant

      hi guys
      i add this code but on order i get store bank accoun and also vendor banckaccoun. How to show just vednor bank account ?
      we have also premium plugins from you if this info can help with custom code.
      thx

    • #115538
      WCFM Forum
      Keymaster

      Hi,

      i add this code but on order i get store bank accoun and also vendor banckaccoun. How to show just vednor bank account ?

      – Do you have added vendor’s Bank details from their setting -> Customer Pay options?

      Thank You

    • #115569
      klub
      Participant
      This reply has been marked as private.
    • #115574
      WCFM Forum
      Keymaster

      Hi,

      Please remove bank details from WooCommerce payment setting. Is this really required for you?

      Thank You

    • #116511
      klub
      Participant

      thx dear firend.

Viewing 6 reply threads
  • The topic ‘Vendor Bank Details in Purchase Confirmation’ is closed to new replies.