I created product attributes based on the selection of attribute yes/no I am calling Ajax to get value and set it in the editor custom attributes but after setting value by jQuery and saving the product it’s not saving.
If the shipping exception is no
If shipping exception yes I am setting the content to the shipping charges attribute but it is not saved. only after clicking on that editor is it saved
CODE
<script>
require(
['jquery','tinymce'],
function ($,tinymce) {
var ajaxurl = '<?php echo $block->getAjaxUrl() ?>';
$(document).on('keyup change', '[name="product[shipping_exception]"]', function () {
var productType = $('[name="product[product_type]"]').val();
var shippingException = $('[name="product[shipping_exception]"]').val();
if (shippingException == 1) {
$.ajax({
url: ajaxurl,
dataType: 'json',
type: 'POST',
data: ({
product_type: productType
}),
//showLoader: true,
success: function (response) {
console.log(response);
if (response.status == 200) {
var data = response.data;
tinymce.get('product_form_pan_shipping_charges').setContent(data.shipping_charges);
tinymce.get('product_form_pan_shipping_info').setContent(data.shipping_info);
tinymce.get('product_form_pan_terms_of_sale').setContent(data.terms_of_sale);
} else {
tinymce.get('product_form_pan_shipping_charges').setContent('');
tinymce.get('product_form_pan_shipping_info').setContent('');
tinymce.get('product_form_pan_terms_of_sale').setContent('');
}
}
});
}
});
});
</script>
Please help me why it’s not saved anything is missing to add.
your help will be appreciated