add attribute or custom field info to add to cart buttonon category page
-
Want to add a custom field or attribute (have info both ways)
simple product.
on category page want add to cart button to include info like “genre:Rock” and add it to cart page so that it carries over to checkout/order pages.I have been able to do it with the single product page ok, but cannot figure it out for the category page.
any suggestions? I would guess I need to somehow modify the woocommerce/loop/add-to-cart.php file. When I add the field there, it does show it in the HREF for the button… but does not carry over into the cart nor order pages.
is there any way to get this to change so that it accepts the custom field info and carries it forwards?
echo apply_filters(
‘woocommerce_loop_add_to_cart_link’, // WPCS: XSS ok.
sprintf(
‘%s‘,
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args[‘quantity’] ) ? $args[‘quantity’] : 1 ),
esc_attr( isset( $args[‘class’] ) ? $args[‘class’] : ‘button’ ),
isset( $args[‘attributes’] ) ? wc_implode_html_attributes( $args[‘attributes’] ) : ”,
esc_html( $product->add_to_cart_text() )
),
$product,
$args
);`
`The page I need help with: [log in to see the link]
- The topic ‘add attribute or custom field info to add to cart buttonon category page’ is closed to new replies.