admin管理员组文章数量:1130349
I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.
I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.
1 Answer
Reset to default 0use this function and edit cart page template
/**
* Display engraving text in the cart.
*
* @param array $item_data
* @param array $cart_item
*
* @return array
*/
function iconic_display_engraving_text_cart( $item_data, $cart_item ) {
if ( empty( $cart_item['iconic-engraving'] ) ) {
return $item_data;
}
$item_data[] = array(
'key' => __( 'Engraving', 'iconic' ),
'value' => wc_clean( $cart_item['iconic-engraving'] ),
'display' => '',
);
return $item_data;
}
add_filter( 'woocommerce_get_item_data', 'iconic_display_engraving_text_cart', 10, 2 );
I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.
I want to add some extra field in the cart page. i mean when a user add some product into cart and pressed view cart button then he can see his selected product with some default field image product price and total but I want add extra field where user can choose an option to get product monthly or weekly. So I want to add an option drop down for each product in the cart page.I saw some plugin but all are working on checkout pages not cart page. So how can I add extra field into the cart page.
1 Answer
Reset to default 0use this function and edit cart page template
/**
* Display engraving text in the cart.
*
* @param array $item_data
* @param array $cart_item
*
* @return array
*/
function iconic_display_engraving_text_cart( $item_data, $cart_item ) {
if ( empty( $cart_item['iconic-engraving'] ) ) {
return $item_data;
}
$item_data[] = array(
'key' => __( 'Engraving', 'iconic' ),
'value' => wc_clean( $cart_item['iconic-engraving'] ),
'display' => '',
);
return $item_data;
}
add_filter( 'woocommerce_get_item_data', 'iconic_display_engraving_text_cart', 10, 2 );
本文标签: woocommerce offtopicHow to customize product at cart page
版权声明:本文标题:woocommerce offtopic - How to customize product at cart page 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749177237a2327999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论