Advertisement
Guest User

WooCommerce Add Cart Product IDs To Checkout Body Class

a guest
Sep 21st, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. // WooCommerce Add Product IDs To Checkout Body Class
  2.  
  3. function woo_cart_items_id_in_body_class( $classes ){
  4.  
  5. $cart = WC()->cart->get_cart();
  6.     foreach( $cart as $cart_item ){
  7.         $product = wc_get_product( $cart_item['product_id'] );
  8.         $classes[] = 'cart-item-id-' . $product->get_id();
  9.     }
  10. return $classes;
  11. }
  12.  
  13. add_filter( 'body_class', 'woo_cart_items_id_in_body_class' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement