Skip to content

Commit

Permalink
Open menu item modal when query string is present
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Oct 22, 2023
1 parent 47aa070 commit 04a7c93
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions assets/js/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,24 @@
window.location.href = pageUrl+$input.attr('name')+'='+$input.val()
})

$(document).render(function () {
setTimeout(function () {
const $body = $('body'),
params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});

if (!params || !params.menuId) return;

const $button = $('<button type="button" data-cart-control="load-item" data-menu-id="' + params.menuId + '"></button>');

$body.prepend($button);
$button.trigger('click');

const uri = window.location.href.toString(),
cleanUri = uri.substring(0, uri.indexOf("?"));

window.history.replaceState({}, document.title, cleanUri);
}, 500);
});
}(jQuery)

0 comments on commit 04a7c93

Please sign in to comment.