Tag: 变种

在WooCommerce变量产品单页中获取所选的产品变体ID

对于我的Woocommerce变量产品,我在单个产品页面上实现了自定义大小的选择器,并在表格中具有以下尺寸: 这些变化只是: 30B 30C 30D而不是分成: 30和B C D 我想弄清楚的是:如何抓住每个产品变化的运输类? 我在购物车页面上有类似的内容,但我不知道变体ID是什么或如何从单个产品页面获取它: $product_id = ( 0 != $cart_item[‘variation_id’] ) ? $cart_item[‘variation_id’] : $cart_item[‘product_id’]; // need the variation id for the above to be able to do the rest: $product_shipping_classes = get_the_terms( $product_id, ‘product_shipping_class’ ); $product_shipping_class_name = ( $product_shipping_classes && ! is_wp_error( $product_shipping_classes ) ) ? current( $product_shipping_classes […]

根据变化更改WooCommerce变量产品标题

我正在寻找一些帮助,让WooCommerce变量产品标题根据变化进行更改。 在这种特定情况下,我希望在选择颜色时更改标题,例如“Productname Black”。 是否有任何简单的片段可以让它发挥作用? 感谢我能得到的所有帮助。

可变产品选择器:获取实时选定值

在WooCommerce中,使用以下代码在简单和变量产品中的产品价格之后添加自定义标签: add_filter(‘woocommerce_variation_price_html’,’prices_custom_labels’, 10, 2 ); add_filter(‘woocommerce_price_html’,’prices_custom_labels’, 10, 2 ); function prices_custom_labels( $price, $product ){ // Set HERE your custom labels names $per_dozen = ‘ ‘. __(‘per dozen’, ‘woocommerce’ ); $per_case = ‘ ‘. __(‘per case (20 dozens)’, ‘woocommerce’ ); // 1) Variable products if ($product->product_type != ‘simple’ && $product->variation_id ) { // Getting the array […]