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
WordPress

How to Identify a Conflicting Theme or Plugin

weDevs use WordPress’ best practices to make it as compatible as possible with all themes and plugins; however, some theme and plugin authors do not adhere to these best practices which can often result in a theme or plugin conflict with our plugins

The following section provides instructions for determining if an issue you are experiencing with our plugin is caused by a theme or plugin conflict.

1. Theme Test
=> Switch to the default WordPress theme as we know that the default WordPress theme is coded properly. Now check and see if the issue is still there. Take note if you see a difference in behavior after you have switched the theme. Switch back to the theme you were using.

2. Plugin Test
If the theme didn’t have anything to do with the issue then move on to the plugins section. There are many WordPress plugins out there and not all of them are coded nicely so let’s see if you have a plugin installed that is not playing nice.

=> Try to deactivate the plugins except for our plugins then check again.

Does the issue remain?

If not, the issue is not caused by our plugin. This may be a WordPress issue, a conflict with your specific setup or something related to your server or webhost. Opening a topic in the WordPress support forums may help point you in the right direction.

If not, continue.

If yes, the issue is caused by our plugin. Create a support ticket on weDevs site for advice.