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:

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

Refer Screenshot:

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:

By Mahbubur Rahman

Self Taught Programmer And Learning Enthusiast

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *