I've been working with WooCommerce recently and I was wondering if it was possible to get cart items via JavaScript or JQuery
I know you can use PHP functions to retrieve the contents of the cart but currently I do not have access to the backend of the site.
I've found a similar question here: WooCommerce cookies and sessions - Get the current products in cart
In the session there is a wc_fragment that contains the HTML of the cart.
{"div.widget_shopping_cart_content":"<div class=\"widget_shopping_cart_content\">\n\n\t<ul class=\"woocommerce-mini-cart cart_list product_list_widget \">\n\t\t\t\t\t\t<li class=\"woocommerce-mini-cart-item mini_cart_item\">\n\t\t\t\t\t<a href=\"https://shop.co.uk/basket/?remove_item=5a48ab5b7a7d18cb26168d874821d031&_wpnonce=3bccfbac25\" class=\"remove remove_from_cart_button\" aria-label=\"Remove this item\" data-product_id=\"12765\" data-cart_item_key=\"5a48ab5b7a7d18cb26168d874821d031\" data-product_sku=\"\">×</a>\t\t\t\t\t\t\t\t\t\t\t<a href=\"https://shop.co.uk/product/?attribute_pa_quantity=1-drink\">\n\t\t\t\t\t\t\t<img width=\"800\" height=\"450\" src=\"https://cdn2.co.uk/app/uploads/Overlapped-800x450.jpg\" class=\"attachment-woocommerce_thumbnail size-woocommerce_thumbnail\" alt=\"\" />Raspberry Drinking Yogurt - 1 drink\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"quantity\">1 × <span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>1.50</span></span>\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\n\t<p class=\"woocommerce-mini-cart__total total\">\n\t\t<strong>Subtotal:</strong> <span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>1.50</span>\t</p>\n\n\t\n\t<p class=\"woocommerce-mini-cart__buttons buttons\"><a href=\"https://shop.co.uk/basket/\" class=\"button wc-forward\">View basket</a><a href=\"https://shop.co.uk/checkout/\" class=\"button checkout wc-forward\">Checkout</a></p>\n\n\t\n\n</div>"}
Would it be possible to extract the elements from this?