First time attempting to implement custom cart attributes but the value is not being passed to the Admin backend in the order info. Site is using AJAX.
cart.liquid file:
{% if section.settings.enable_sales_dropdown %}
## Salesperson
*Please choose the salesperson that you worked with on this order below. If you did not work with a salesperson, please choose "None"
{% endif %}
JS file (Copied logic from the notes to create the custom cart field):
/* Sales Agent Cart Select */
theme.cartSalesAgentMonitor = {
load: function load($salesAgent) {
$salesAgent.on('change.themeCartSalesAgentMonitor paste.themeCartSalesAgentMonitor keyup.themeCartSalesAgentMonitor', function () {
theme.cartSalesAgentMonitor.postUpdate($(this).val());
});
},
unload: function unload($salesAgent) {
$salesAgent.off('.themeCartSalesAgentMonitor');
},
updateThrottleTimeoutId: -1,
updateThrottleInterval: 500,
postUpdate: function postUpdate(val) {
clearTimeout(theme.cartSalesAgentMonitor.updateThrottleTimeoutId);
theme.cartSalesAgentMonitor.updateThrottleTimeoutId = setTimeout(function () {
$.post(theme.routes.cart_url + '/update.js', {
attributes: val },
function (data) {}, 'json');
}, theme.cartSalesAgentMonitor.updateThrottleInterval);
} };
/* End Sales Agent Cart Select */
/* Original Theme Code */
theme.cartNoteMonitor = {
load: function load($notes) {
$notes.on('change.themeCartNoteMonitor paste.themeCartNoteMonitor keyup.themeCartNoteMonitor', function () {
theme.cartNoteMonitor.postUpdate($(this).val());
});
},
unload: function unload($notes) {
$notes.off('.themeCartNoteMonitor');
},
updateThrottleTimeoutId: -1,
updateThrottleInterval: 500,
postUpdate: function postUpdate(val) {
clearTimeout(theme.cartNoteMonitor.updateThrottleTimeoutId);
theme.cartNoteMonitor.updateThrottleTimeoutId = setTimeout(function () {
$.post(theme.routes.cart_url + '/update.js', {
note: val },
function (data) {}, 'json');
}, theme.cartNoteMonitor.updateThrottleInterval);
} };
/* Original Theme Code */
/* Code Located In Other Areas Of File Wrapped In Other Functions */
theme.cartNoteMonitor.load($('.checkout-note [name="note"]', container));
theme.cartSalesAgentMonitor.load($('.checkout-salesAgent [name="properties[Choose Associate]"]', container));
this.onSectionUnload = function (container) {
$(document).off('.cartTemplateSection');
$(container).off('.cartTemplateSection');
theme.cartNoteMonitor.unload($('.checkout-note [name="note"]', container));
theme.cartSalesAgentMonitor.unload($('.checkout-salesAgent [name="properties[Choose Associate]"]', container));
};