WC_Embed::the_excerpt()
Create the excerpt for embedded products - we want to add the buy button to it.
Method of the class: WC_Embed{}
No Hooks.
Return
String
.
Usage
$result = WC_Embed::the_excerpt( $excerpt );
- $excerpt(string) (required)
- Embed short description.
Changelog
Since 2.4.11 | Introduced. |
WC_Embed::the_excerpt() WC Embed::the excerpt code WC 9.7.1
public static function the_excerpt( $excerpt ) { global $post; // Get product. $_product = wc_get_product( get_the_ID() ); // Make sure we're only affecting embedded products. if ( self::is_embedded_product() ) { echo '<p><span class="wc-embed-price">' . $_product->get_price_html() . '</span></p>'; // WPCS: XSS ok. if ( ! empty( $post->post_excerpt ) ) { ob_start(); woocommerce_template_single_excerpt(); $excerpt = ob_get_clean(); } // Add the button. $excerpt .= self::product_buttons(); } return $excerpt; }