wcfm-santa

A deal you can't resist! Get upto 25% Off on this entire cyber week.

CLAIM OFFER
00Day 17Hr 09Min 52Sec
wcfm-santa

Set every vendor product as a single purchase and disable stock management

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!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Set every vendor product as a single purchase and disable stock management

Viewing 3 reply threads
  • Author
    Posts
    • #85011
      contatoapp
      Participant

      If I enable stock management for all vendors, they can manually set a product as a single purchase (meaning there’s only 1 in stock).

      I’m building a book marketplace where vendors will anounce their new/used books, but to stop them from bundling new and used books in a single purchase (since the books are gonna be categorized under their conservation status), I want every vendor product to be registered as a single purchase, preventing fraud.

      But even if I disable stock management for vendors, users can still select the amount of products on the product’s page (see attached image) because, I assume, since there’s no stock management, that means the products will be delivered on demand and/or there’s an indefinite amount in stock.

      Is that possible? Thanks in advance!

      Attachments:
      You must be logged in to view attached files.
    • #86199
      WCFM Forum
      Member

      Hi,

      Keep stock management enable and add this code to your site, hence vendors will not able to manage stock from their products –

      add_filter( 'wcfm_product_fields_stock', function( $stock_fields, $product_id, $product_type ) {
      	if( !$product_id ) {
      		if( isset( $stock_fields['manage_stock'] ) ) {
      			$stock_fields['manage_stock']['dfvalue'] = 'enable';
      		}
      		if( isset( $stock_fields['stock_qty'] ) ) {
      			$stock_fields['stock_qty']['value'] = 1;
      		}
      		if( isset( $stock_fields['sold_individually'] ) ) {
      			$stock_fields['sold_individually']['dfvalue'] = 'enable';
      		}
      	}
      	$stock_fields = wcfm_hide_field( 'manage_stock', $stock_fields );
      	$stock_fields = wcfm_hide_field( 'stock_status', $stock_fields );
      	$stock_fields = wcfm_hide_field( 'stock_qty', $stock_fields );
      	$stock_fields = wcfm_hide_field( 'backorders', $stock_fields );
      	$stock_fields = wcfm_hide_field( 'sold_individually', $stock_fields );
        return $stock_fields;
      }, 50, 3 );

      It will set product stock always “1” as well.

      Thank You

    • #102146
      contatoapp
      Participant

      Hello. Awesome, this works just as expected.

      If I could ask something else, I’d like to know if it’s possible to set this condition only to store vendors, but still enable stock management for store managers and admin.

      Thanks in advance.

    • #106043
      WCFM Forum
      Member

      Hi,

      Sure, use this revised code to make this applicable only for vendor users –

      add_filter( 'wcfm_product_fields_stock', function( $stock_fields, $product_id, $product_type ) {
      	if( wcfm_is_vendor() ) {
      		if( !$product_id ) {
      			if( isset( $stock_fields['manage_stock'] ) ) {
      				$stock_fields['manage_stock']['dfvalue'] = 'enable';
      			}
      			if( isset( $stock_fields['stock_qty'] ) ) {
      				$stock_fields['stock_qty']['value'] = 1;
      			}
      			if( isset( $stock_fields['sold_individually'] ) ) {
      				$stock_fields['sold_individually']['dfvalue'] = 'enable';
      			}
      		}
      		$stock_fields = wcfm_hide_field( 'manage_stock', $stock_fields );
      		$stock_fields = wcfm_hide_field( 'stock_status', $stock_fields );
      		$stock_fields = wcfm_hide_field( 'stock_qty', $stock_fields );
      		$stock_fields = wcfm_hide_field( 'backorders', $stock_fields );
      		$stock_fields = wcfm_hide_field( 'sold_individually', $stock_fields );
      	}
        return $stock_fields;
      }, 50, 3 );

      Thank You

Viewing 3 reply threads
  • The topic ‘Set every vendor product as a single purchase and disable stock management’ is closed to new replies.