Suppose you have a text link: Checkout on Announcement Bar, and a product on your site. You want: When users click on this Checkout link >> It will add the product to the cart and open the checkout page.
(1) First, add a text: Checkout on Announcement Bar > Highlight it > Add a Link > Enter URL, you can use any url what you want, but make sure “Open in New Tab” option is disabled.
(2) Next, Enable Express Checkout
(3) Add a Product Block to Site Footer
(4) Use this code to Code Injection > Footer
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).on('click', '#announcement-bar-text-inner-id p a', function(event) {
event.preventDefault();
$('div.sqs-add-to-cart-button').click();
});
</script>