• Help us and get rewarded with 15% discount coupon. Learn how

Duplicate product button in the "Edit Product" screen

WooCommerce Multivendor Marketplace – Home Forums WCfM – Feature Request Duplicate product button in the "Edit Product" screen

This topic contains 5 replies, has 2 voices, and was last updated by WCfM Forum WCfM Forum 3 months, 1 week ago.

  • Author
    Posts
  • #61139
    Avatar
    sadoun
    Participant

    Can you please add “Duplicate Product” button in the “Edit Product” screen? put it beside the “Add New” button.

    For example this would be extremely handy for vendors who have similar products with slight variation. Once they add a product and submit it, then when the screen refreshes, they can just click on “Duplicate Product” and make another copy. They can edit the copy and submit it, then make another copy. This will save time and make it faster to add products

    Attachments:
    You must be logged in to view attached files.
  • #61661
    WCfM Forum
    WCfM Forum
    Keymaster

    Hi,

    Please add this code to your child theme’s functions.php for the purpose –

    add_action( 'after_wcfm_products_manage_action', function() {
    	global $wp;
    	if( isset( $wp->query_vars['wcfm-products-manage'] ) && !empty( $wp->query_vars['wcfm-products-manage'] ) ) {
    		echo '<a id="wcfm_product_duplicate" class="wcfm_product_duplicate add_new_wcfm_ele_dashboard text_tip" href="#" data-proid="'. $wp->query_vars['wcfm-products-manage'] .'" data-tip="' . __('Duplicate Product', 'wc-frontend-manager') . '"><span class="wcfmfa fa-copy"></span><span class="text">' . __( 'Duplicate Product', 'wc-frontend-manager') . '</span></a>';
    		?>
    		<script>
    		jQuery(document).ready(function($) {
    			$('#wcfm_product_duplicate').click(function(event) {
    				event.preventDefault();
    				jQuery('#wcfm_products_manage_form').block({
    					message: null,
    					overlayCSS: {
    						background: '#fff',
    						opacity: 0.6
    					}
    				});
    				var data = {
    					action : 'wcfmu_duplicate_product',
    					proid : $(this).data('proid')
    				}	
    				jQuery.ajax({
    					type:		'POST',
    					url: wcfm_params.ajax_url,
    					data: data,
    					success:	function(response) {
    						if(response) {
    							$response_json = $.parseJSON(response);
    							if($response_json.status) {
    								if( $response_json.redirect ) window.location = $response_json.redirect;	
    							}
    						}
    					}
    				});
    				return false;
    			});
    		});
    		</script>
    		<?php
    	}
    }, 50 );

    Thank You

  • #61802
    Avatar
    sadoun
    Participant

    Thank you for your efforts… Sorry this code did not work. No button appeared… Can you please look into it and add this feature… It is really good to have

  • #61803
    Avatar
    sadoun
    Participant

    You can add the “Duplicate” button new “Add New” or near “View” “Draft” “Submit” buttons.

    Attachments:
    You must be logged in to view attached files.
  • #61805
    Avatar
    sadoun
    Participant

    Ok, the code above works now. Thank you very much. You are so helpful.

  • #61907
    WCfM Forum
    WCfM Forum
    Keymaster

    Great … you are welcome 🙂

The topic ‘Duplicate product button in the "Edit Product" screen’ is closed to new replies.