Replies: 0
Hi there,
I’ve added some Advanced Custom Fields to my product pages. Those fields appear on the product page just fine, and I was also able to make it work pulling those fields in to the cart. But I’m having trouble figuring out how to also echo those fields in the “Your Order” review area of the checkout page. Hoping someone can assist. The fields in question are the show name, and venue (which is being pulled via post_object in a custom post type). Here’s my checkout code:
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . ' '; ?>
<br /><?php the_field('show_name', $product_id);
$venue_object = get_field('event_location', $product_id);
if( $venue_object ):
$venue_street = get_field('street_address', $venue_object->ID);
$venue_city = get_field('city', $venue_object->ID);
$venue_state = get_field('state', $venue_object->ID);
$venue_zip = get_field('zipcode', $venue_object->ID);
?>
<br /><?php echo $venue_object->post_title; ?><br />
<?php echo $venue_street; ?><br />
<?php echo $venue_city; ?>, <?php echo $venue_state; ?> <?php echo $venue_zip;
endif; ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
<?php echo WC()->cart->get_item_data( $cart_item ); ?>
</td>
<td class="product-total">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>