Jump to content

Edit History

timot

timot

Thanks for your answer @ps8modules

Sorry I try to keep it simple as much as possible... It's true I use is_shoppingcart and I don't really know how much it differs from ps_shoppingcart...
My question might be misplaced ?


Then I try to copy this ajax function but no matter what, I can't get this modal content :

I'm trying to keep it short :

const refreshURL = document.querySelector('.js-blockcart').dataset.refreshUrl;
let requestData = {};
requestData = {
	ajax: 1,
};
requestData = Object.keys(requestData).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`).join('&');

fetch(refreshURL, {
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
	},
	body: requestData,
	})
	.then((resp) => resp.json())
	.then((resp) => {
		if (resp.modal) {
			showModal(resp.modal);
		}
	})

refreshURL is set to /module/is_shoppingcart/ajax

With this code I do have a resp.preview but I don't get any resp.modal

Whereas in the orginal function the only difference (I think) was that requestData were more populated (because of the updating of the cart) :

requestData = {
  id_customization: event.reason.idCustomization,
  id_product_attribute: event.reason.idProductAttribute,
  id_product: event.reason.idProduct,
  action: event.reason.linkAction,
  ajax: 1,
};

And resp.modal was filled.

Would you think of any way to force this modal setting while fetching /module/is_shoppingcart/ajax ?

timot

timot

Thanks for your answer @ps8modules

Sorry I try to keep it simple as much as possible... It's true I use is_shoppingcart and I don't really know how much it differs from ps_shoppingcart...
My question might be misplaced ?


Then I try to copy this ajax function but no matter what, I can't get this modal content :

I'm trying to keep it short :

const refreshURL = document.querySelector('.js-blockcart').dataset.refreshUrl;
let requestData = {};
requestData = {
	ajax: 1,
};
requestData = Object.keys(requestData).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`).join('&');

fetch(refreshURL, {
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
	},
	body: requestData,
	})
	.then((resp) => resp.json())
	.then((resp) => {
		if (resp.modal) {
			showModal(resp.modal);
		}
	})

refreshURL is set to /module/is_shoppingcart/ajax

With is code I do have a resp.preview but I don't get any resp.modal

Whereas in the orginal function the only difference (I think) was that requestData were more populated (because of the updating of the cart) :

requestData = {
  id_customization: event.reason.idCustomization,
  id_product_attribute: event.reason.idProductAttribute,
  id_product: event.reason.idProduct,
  action: event.reason.linkAction,
  ajax: 1,
};

And resp.modal was filled.

Would you think of any way to force this modal setting while fetching /module/is_shoppingcart/ajax ?

timot

timot

Then I try to copy this ajax function but no matter what, I can't get this modal content :

I'm trying to keep it short :

const refreshURL = document.querySelector('.js-blockcart').dataset.refreshUrl;
let requestData = {};
requestData = {
	ajax: 1,
};
requestData = Object.keys(requestData).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`).join('&');

fetch(refreshURL, {
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
	},
	body: requestData,
	})
	.then((resp) => resp.json())
	.then((resp) => {
		if (resp.modal) {
			showModal(resp.modal);
		}
	})

refreshURL is set to /module/is_shoppingcart/ajax

With is code I do have a resp.preview but I don't get any resp.modal

Whereas in the orginal function the only difference (I think) was that requestData were more populated (because of the updating of the cart) :

requestData = {
  id_customization: event.reason.idCustomization,
  id_product_attribute: event.reason.idProductAttribute,
  id_product: event.reason.idProduct,
  action: event.reason.linkAction,
  ajax: 1,
};

And resp.modal was filled.

Would you think of any way to force this modal setting while fetching /module/is_shoppingcart/ajax ?

×
×
  • Create New...