Mahbubur Rahman

Thoughts and Writings

06 Mar 2017
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

1 Comments
  1. Bablofil March 21, 2017 at 9:44 am

    Thanks, great article.

  2. IZRAELving July 28, 2019 at 10:11 pm
    Your comment is awaiting moderation.

    credit one bank payment address

    Mo and mo ~ Video
    Maitre Mo – Petite chronique judiciaire, ordinaire et subjective, alimentee quand elle le peut, par un avocat au Barreau de Lille Mo and mo Petite chronique judiciaire, ordinaire et subjective, alimentee quand elle le peut, par un avocat au Barreau de Lille Les deux costauds [L’histoire qui suit n’est pas racontee par moi mais par Eric Morain, confrere parisien rencontre sur Twitter et devenu un ami. Elle le travaillait, comme on dit, depuis un moment. Le hasard veut qu’il ait pu la coucher sur le papier maintenant, dans le contexte assez particulier de tres nombreuses accusations de meme nature qui …
    The post Mo and mo ~ Video appeared first on Income.

    [url=http://insurances.remmont.com]Lexingtone Finance[/url]

Leave a Comment

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