Shopify结账动态生成html类?
我即将到达结帐处以获取最终支付价格:
let checkout = await fetch("/checkout/");
checkout = await checkout.text();
let total_price = checkout.match(
/<dl class="order-summary-toggle(.*?)<\/dl>/gim
);
问题是我注意到在某些商店结帐页面上有动态生成的类,但我不知道为什么并且无法重现?
有人知道为什么会发生吗?或者是否有更好的方法来获取结账最终价格?
I'm reaching the checkout for getting the final price to pay :
let checkout = await fetch("/checkout/");
checkout = await checkout.text();
let total_price = checkout.match(
/<dl class="order-summary-toggle(.*?)<\/dl>/gim
);
The problem is i noticed on some store checkout page got dynamic generated class, and i dont know why and cant reproduce?
Is someone know why is it happening ? or if there is an better way to get the checkout final price ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
html 不会完整,因为是使用 Javascript 动态创建的。
如果您使用的是液体,则可以使用
{{cart.total_price}}
访问总价。如果没有,并且您想使用 cartjs api 您可以调用
/cart.js
并使用字段“total_price”The html will not be complete because is dynimically created with Javascript.
If you are using liquid the total price can be accessed with
{{cart.total_price}}
.If not, and you want to use the cartjs api you can call
/cart.js
and use the field "total_price"