Save colors into Woocommerce settings

[MAILPOET-2278]
This commit is contained in:
Amine Ben hammou
2019-10-17 07:33:32 +01:00
committed by Jack Kitterhing
parent 86cffacdbe
commit 661488a14f
2 changed files with 14 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import _ from 'underscore';
import MailPoet from 'mailpoet';
import App from 'newsletter_editor/App';
import BaseBlock from 'newsletter_editor/blocks/base';
@ -30,6 +31,17 @@ const SettingsView = BaseBlock.BlockSettingsView.extend({
'click .mailpoet_done_editing': 'close',
};
},
close: function close() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'woocommerce_settings',
action: 'set',
data: {
woocommerce_email_base_color: this.model.get('styles.backgroundColor'),
},
});
this.destroy();
},
});
const BlockToolsView = BaseBlock.BlockToolsView.extend({

View File

@ -20,6 +20,8 @@ Module.save = function () {
// Stringify to enable transmission of primitive non-string value types
if (!_.isUndefined(json.body)) {
delete json.body.blockDefaults.woocommerceHeading;
delete json.body.blockDefaults.woocommerceContent;
json.body = JSON.stringify(json.body);
}