Advertisement
simkoG

WC attributes

Mar 7th, 2023 (edited)
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. <?php
  2.  
  3. function acme_wc_attributes() {
  4.     global $product;
  5.  
  6.     echo "<pre>";
  7.  
  8.     foreach( $product->get_attributes() as $attr ) {
  9.         printf(
  10.             "%s: %s" . PHP_EOL,
  11.             wc_attribute_label( $attr->get_name() ),
  12.             implode( ', ', $attr->get_options() )
  13.         );
  14.     }
  15.  
  16.     echo "</pre>";
  17. }
  18.  
  19. add_action( 'woocommerce_after_single_product', 'acme_wc_attributes' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement