私は以下のコードで行ったバリエーションの株式テキストを探したいですが、私は適切な方法を探しています。 woocommereceプラグインのファイルtemplates/single-product/add-to-cart/variable.php
から以下のコードを取得します。助けていただければ幸いです。どのように変動株を見つけるためにwoocommerece
$terms = wc_get_product_terms($product->id, $attribute, array('fields' => 'all'));
foreach ($terms as $term) {
if (in_array($term->slug, $options)) {
$product_variations_cus = $product->get_available_variations(); // my custom code start from here
foreach($product_variations_cus as $var_cus){
foreach($var_cus['attributes'] as $stock) {
if($term->slug==$stock)
$availability_html = $var_cus['availability_html']; // end here
}
}
$html .= '<option value="' . esc_attr($term->slug) . '" ' . selected(sanitize_title($args['selected']), $term->slug, false) . '>' . esc_html(apply_filters('woocommerce_variation_option_name', $term->name)) .' '.$availability_html.'</option>';
}
}
実際には、私は画像で見ることができますvarationドロップダウンにストックテキストを追加したいと思います。
はあなたがバディありがとうございます。うん、私はそれを知っているが、私はterm_idまたは用語スラグでこのコードが欲しい。私はterm_idを渡したいと思っています。 – Coder
あなたは私のコードで最後に私は株式などに書いている選択オプションを見ることができます – Coder