Untitled
unknown
plain_text
a year ago
1.5 kB
9
Indexable
add_action('marketking_after_add_product_my_store', function($product){
update_post_meta($product->get_id(), 'marketking_added_to_store', 'yes');
}, 10, 1);
add_action('marketking_edit_product_after_tags', function($post){
// show if product was added to store or not
$added_to_store = get_post_meta($post->ID, 'marketking_added_to_store', true);
if ($added_to_store === 'yes'){
?>
<input type="hidden" id="marketking_added_to_store" value="yes">
<?php
}
}, 10, 1);
add_action('marketking_dashboard_head', function(){
?>
<script>
jQuery(document).ready(function(){
if ($('#marketking_added_to_store').val() === 'yes'){
// product was added to store
$('#marketking_product_title, #_weight, #product_length, #product_width, #product_height').prop('readonly', true);
$('._low_stock_amount_field, ._backorders_field, #product-type, .add_product_images, .delete.tips, .marketking_edit_product_image_explainer').remove();
$('#marketking_edit_product_main_image').off('click');
$('#postexcerpt, #shortpostexcerpt, .marketking_categories_block, .marketking_tags_block').css('opacity', '0.5').css('pointer-events', 'none');
}
});
</script>
<?php
});
add_action('marketking_before_save_product', function($product_id, $vendor_id){
// prevent vendor from editing products programmatically
$added_to_store = get_post_meta($product_id, 'marketking_added_to_store', true);
if ($added_to_store === 'yes'){
$_POST['title'] = get_the_title($product_id);
}
}, 10, 2);
Editor is loading...
Leave a Comment