Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将id添加到按钮添加到Woocomece购物车_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 如何将id添加到按钮添加到Woocomece购物车

Php 如何将id添加到按钮添加到Woocomece购物车,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,有人知道我如何将id添加到woocommerce按钮,woocommerce添加了这种结构 <button type="submit" data-quantity="1" data-product_id="id_del_producto" class="button alt ajax_add_to_cart add_to_cart_button product_type_simple" > Agregar al Carrito </button>

有人知道我如何将id添加到woocommerce按钮,woocommerce添加了这种结构

<button type="submit" data-quantity="1" data-product_id="id_del_producto" 
    class="button alt ajax_add_to_cart add_to_cart_button product_type_simple" >
       Agregar al Carrito
</button>

这必须是在所有的按钮,我想我必须修改
添加到cart.php
文件,但我不知道如何做,我不是很擅长php,我感谢你的回答,谢谢

如果不是
add_to_cart.php
试试
simple.php
你会在
wp content/plugins/woocommerce/templates/single product/add to cart
中找到所有按钮的变体,或者如果你正在使用一个支持woocommerce的主题,试着在主题的woocommerce文件夹中找到它


然后您只需添加这行代码
id=“id”

@RamRaider嗨,对不起,我用错误的语言问了这个问题,我已经纠正了。没问题-如果您认为代码需要更改,可能需要添加
add to cart.php
。@RamRaider好吧,它必须在那里,因为它必须在所有按钮上,我真的不知道像你一样我也不知道从未使用过
woo commerce
,但其他人可能知道..@RamRaider我理解,无论如何谢谢你的评论Hello,谢谢你的回复,我正在使用puglin在woo commerce按钮中添加金额,因此它没有模板,最后我用这个解决了它”。esc_html($product->add_to_cart_text())。'
<button type="submit" data-quantity="1" data-product_id="id_del_producto" 
    class="button alt ajax_add_to_cart add_to_cart_button product_type_simple" id="id604">
     Agregar al Carrito
</button>