获取名称分类

时间:2018-12-29 12:56:22

标签: php wordpress

我有下面的代码,我试图获取名称产品分类法,但是却得到了产品塞分类法。我该如何更改?

function woocommerce_variable_add_to_cart() {

    global $product, $post;
    $variations = $product->get_available_variations();
    foreach ($variations as $key => $value) {
    ?>
    <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"method="post" enctype='multipart/form-data'>
        <input type="hidden" name="variation_id" value="<?php echo $value['variation_id']?>" />
        <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
        <?php
        if(!empty($value['attributes'])){
            foreach ($value['attributes'] as $attr_key => $attr_value) { ?>
                <input type="hidden" name="<?php echo $attr_key?>" value="<?php echo $attr_value?>"> <?php
            }
        }
        ?>
        <li><table id="bookprice">
            <tbody><tr><td class="bookbutton">
                <button type="submit" class="nm-variable-add-to-cart-button single_add_to_cart_button button alt">
                <?php echo esc_html( $product->single_add_to_cart_text() ); ?> 
                <?php echo implode('/', $value['attributes']);?> | <?php echo $value['price_html'];?>
                </button>
                <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
                <input type="hidden" name="add-to-cart" value="<?php echo absint( $product->get_id() ); ?>" />
                <input type="hidden" name="product_id" value="<?php echo absint( $product->get_id() ); ?>" />
                <input type="hidden" name="variation_id" class="variation_id" value="0" /></td>
                </tr></tbody>
            </table>
    <li>
    </form> <?php
    }
}

整个代码:https://pastebin.com/b8eTas4F

0 个答案:

没有答案