Categories
Plugins WooCommerce

How to limit min and max quantity for WooCommerce

Min and Max Quantity for WooCommerce plugin allow you to set up limits for the cost of products in orders and in groups and limits for the number of products, product variations, products in orders, and products in the group. You can add products and product variations to the group. An infinite amount of groups.

FEATURES:
✅ Quantity limits for products
✅ Quantity limits for product variations
✅ Quantity limits for products in cart
✅ Cost limits for products in cart

ADDITIONAL FEATURES IN PAID PLUGIN:
✅ Quantity limits for groups of products
✅ Quantity limits for products from categories
✅ Quantity limits for products from specific attributes
✅ Cost limits for groups of products
✅ Cost limits for products from categories
✅ Cost limits for products from specific attributes
✅ Infinite groups of products

Categories
Plugins WP User Frontend

How to create form for uploading external/affiliate type WooCommerce product

The process for creating a form to upload external/affiliate type product given here.

1) Add a hidden type field with meta key & value to your product form. The meta value should be external.

Refer Screenshot:
http://prntscr.com/egkcws

2) Add an URL & a text type custom field, insert _product_url & _button_text meta key for them respectively.

Refer Screenshot:
http://prntscr.com/egkdox

3) Add the following code inside the theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
function wpuf_support_external_product( $post_id ) {
   
    $product_type = get_post_meta( $post_id, 'product_type', true );

    wp_set_object_terms( $post_id, $product_type, 'product_type' );
   
}

add_action( 'wpuf_add_post_after_insert', 'wpuf_support_external_product' );
add_action( 'wpuf_edit_post_after_update', 'wpuf_support_external_product' );

Now, check the form on the frontend, try to upload a product & check the submitted product type in wp-admin. The product type should be external/affiliate.

Reference Video:
https://www.youtube.com/watch?v=i2NDYqlAqjo

Categories
Plugins WP User Frontend

How to show all the posts submitted by all users in a page

To show all the posts submitted by all users in a page, follow the instructions given here.

1) Create a new page, insert [wpuf_dashboard] shortcode in that page & Publish it.

Refer Screenshot:
http://prntscr.com/egiu0w

2) Add the following code inside the theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
function show_all_posts_for_admin( $args  ) {

    if ( current_user_can( 'administrator' ) ) {
        unset($args['author']);
        return $args;
    }else {
        return $args;
    }

}

add_filter( 'wpuf_dashboard_query', 'show_all_posts_for_admin' );

Now, logged in from multiple users account & submit posts using frontend form, check the page you created on the frontend. You can see all the posts submitted by all users on that page.

Categories
Plugins WordPress WP User Frontend

How to add user id as product SKU with WP User Frontend product form.

You can follow the instructions given below to insert user id as product SKU.

1) Add a hidden field to the product form you created & insert _sku meta key to that field.

​Refer Screenshot:
http://prntscr.com/ef1e0f

2) Now, Add the following code inside the theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.


function wpuf_update_product_sku( $post_id ) {
   
    if ( isset( $_POST['_sku'] ) ) {

            $user_id = get_current_user_id();
            update_post_meta( $post_id, '_sku', $user_id );

    }

}

add_action( 'wpuf_edit_post_after_update', 'wpuf_update_product_sku' );
add_action( 'wpuf_add_post_after_insert', 'wpuf_update_product_sku' );

​​

​All done, submit a product using frontend product form & check the product SKU in wp-admin. The SKU id will be the user id.

Categories
Plugins WooCommerce WordPress WP User Frontend

How to create unique SKU with WP User Frontend custom field.

The unique SKU of the products is not being set when the products are created. To add unique SKU with products, then follow the instructions given below.

1) Add a custom text field with _sku to the product form.

Screenshot:
http://prntscr.com/eb2ext

2) Add the following code inside the theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
function wpuf_unique_product_sku_notice( $error ) {
    if ( isset( $_POST['_sku'] ) ) {
        global $wpdb;

        $sku = $_POST['_sku'];

        $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

        if ( $product_id ) {
            return __( 'SKU is not unique, you must enter unique SKU' );
        }
    }

    return '';
}

add_filter( 'wpuf_update_post_validate', 'wpuf_unique_product_sku_notice' );
add_filter( 'wpuf_add_post_validate', 'wpuf_unique_product_sku_notice' );

3) Now, try to submit a product using the frontend product form. Use an existing SKU related to other product. You will see the following error.

Screenshot:

All done.

Categories
Plugins WordPress WP User Frontend

How to update WooCommerce sale price dates meta using WPUF date fields

If you are having an issue with updating the schedule dates of WooCommerce product using WPUF fields, you can follow the given instructions to solve this issue.

1) Add two date type field to WPUF form that you created to allow users for uploading products.

2) Insert _sale_price_dates_from & _sale_price_dates_to meta keys accordingly for these two fields.

Refer Screenshot:
http://prntscr.com/du6fqj

3) Change the date format of WPUF date field.

Refer Screenshot:
http://prntscr.com/du66dq

4) Now, add the following code inside the theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
function update_product_schedule_date_meta( $post_id ) {
    $dates_from = get_post_meta( $post_id, '_sale_price_dates_from', true );
    $dates_to = get_post_meta( $post_id, '_sale_price_dates_to', true );

    $dates_from = strtotime($dates_from);
    $dates_to = strtotime($dates_to);

    update_post_meta( $post_id, '_sale_price_dates_from', $dates_from );
    update_post_meta( $post_id, '_sale_price_dates_to', $dates_to );
}

add_action( 'wpuf_add_post_after_insert', 'update_product_schedule_date_meta' );
add_action( 'wpuf_edit_post_after_update', 'update_product_schedule_date_meta' );

All done, add a product from the frontend with the sales price and insert dates for sales from, sales to fields. The fields data will update properly to WooCommerce sale price dates.

Categories
WP User Frontend

How to charge different amount for different post type using WP User Frontend subscription pack

Here is the guideline for charging a different amount for different post types.

1) Navigate to wp-admin > User Frontend > Subscription. Click on Add New Subscription button to add new subscription.

2) Now, You can see the fields to enter the number for each post.

3) If you want to allow only one post type for that pack then enter the number for that post type field, keep value 0 for other post types.

3) Click on “Publish” button to publish that pack.

All done, now users can only submit to that specific post type after purchasing this pack.

Categories
Dokan Multivendor Plugins

How can redirect to the “seller dashboard” instead of seller setup wizard

To define the seller dashboard page instead of setup wizard after registering as a new seller, you can add the following code to your theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
// define the seller dashboard page instead of setup wizard to redirect after registering as a new seller.
add_filter( 'woocommerce_registration_redirect', 'custom_woocommerce_registration_redirect', 11, 1 );
function custom_woocommerce_registration_redirect( $var ) {
    $url  = $var;
    $user = wp_get_current_user();

    if ( in_array( 'seller', $user->roles ) ) {
        $url = dokan_get_navigation_url('/dashboard');
    }


    return $url;
}
Categories
Plugins WooCommerce

How to display quantity input fields next to add to cart buttons.

To display quantity input fields for simple products within your shop archive pages, you can add the following code to your theme’s functions.php file.

Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, contact me for assistance.
<?php
/**
 * Code should be placed in your theme functions.php file.
 */

add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
    if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
        $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
        $html .= woocommerce_quantity_input( array(), $product, false );
        $html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
        $html .= '</form>';
    }
    return $html;
}