Advertisement
orenchuck

CrazyLine add to cart onClick

Jun 6th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var data = "product=271317&selected_configurable_option=&related_product=&form_key=s5piFgV5L9gg3MTo&super_attribute%5B93%5D=29&super_attribute%5B158%5D=43&qty=1";
  2. var url = "https://www.crazyline.com/checkout/cart/add/uenc/aHR0cHM6Ly93d3cuY3JhenlsaW5lLmNvbS9tMTYzODg3MTA,/product/271317/";
  3.  
  4. fetch(url, {
  5.     method: 'POST',
  6.     headers: {
  7.         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
  8.     },
  9.     body: data
  10. }).then(function() {
  11.     require(['Magento_Customer/js/customer-data'], function(customerData) {
  12.         var sections = ['cart'];
  13.         customerData.invalidate(sections);
  14.         customerData.reload(sections, true);
  15.         document.location.reload();
  16.     });
  17. }).catch(function(err) {
  18.     console.log(err)
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement