woocommerce 的变化 [英] woocommerce variations
问题描述
我正在创建一个 woocommerce 主题,我有产品变体,即显示在产品详细信息页面上的尺寸,但问题是我想通过使用产品 ID 在我的自定义 php 页面中获取所有变体,任何人都可以帮助我.
I am creating a woocommerce theme and I have product variations i.e. size which is displayed on product details page but problem is that I want to get all variations in my custom php page by using product id, can any one help me.
提前致谢.
推荐答案
您可以使用:$available_variations = $product->get_available_variations();
如果这是单个样式模板,请确保在顶部附近添加 global $product;
.
If this is a single style template, make sure you add global $product;
near the top.
从那里,您可以通过变体进行 foreach 并按照您的意愿做...因为您没有任何特定的输出,我希望这能让您走上正轨.
From there, you can foreach through the variations and do as you wish... since you didn't have any specific output I hope that this sets you on the right track.
这篇关于woocommerce 的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!