Untitled

 avatar
unknown
plain_text
2 years ago
1.7 kB
4
Indexable
global $marketkingpro_public;
remove_action('woocommerce_after_add_to_cart_button',array($marketkingpro_public, 'add_to_my_store_button'), 100);


remove_action('woocommerce_after_add_to_cart_button', 'add_to_my_store_button_custom', 100);

function add_to_my_store_button_custom(){
	// show button
	if (is_product()){
		global $post;
		if(intval($post->ID) === intval(get_queried_object_id())){
			if (marketking()->is_vendor(get_current_user_id())){	

				// only show if not my product + I don't already have it added in my store
				if (get_current_user_id() !== intval(marketking()->get_product_vendor($post->ID))){
					if(!marketking()->vendor_has_linkedproduct(get_current_user_id(), $post->ID)){
						// if has not already been shown on the page
						global $marketking_add_my_store_has_shown;
						if (empty($marketking_add_my_store_has_shown)){
							$marketking_add_my_store_has_shown = false;
						}
						if ($marketking_add_my_store_has_shown === false){
							ob_start();
							?>
							<button type="button" id="marketking_add_product_to_my_store" name="marketking_add_product_to_my_store" value="<?php echo esc_attr($post->ID);?>"><div id="marketking_add_product_to_my_store_icon"></div><span class="dashicons <?php echo esc_attr(apply_filters('marketking_add_product_to_my_store_icon','dashicons-clipboard'));?>"></span>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo apply_filters('marketking_add_product_to_my_store_text',esc_html__('Add product to my store','marketking'));?></button>
							<?php
							$button = apply_filters('marketking_add_product_to_my_store_button', ob_get_clean(), $post->ID);
							echo $button;
							$marketking_add_my_store_has_shown = true;
						}
						
					}
				}
				
			}
		}
	}
}
Editor is loading...