WC_Embed::product_buttons()
Create the button to go to the product page for embedded products.
Description Description
Return Return
(string)
Source Source
File: includes/class-wc-embed.php
public static function product_buttons() {
$_product = wc_get_product( get_the_ID() );
$buttons = array();
$button = '<a href="%s" class="wp-embed-more wc-embed-button">%s</a>';
if ( $_product->is_type( 'simple' ) && $_product->is_purchasable() && $_product->is_in_stock() ) {
$buttons[] = sprintf( $button, esc_url( add_query_arg( 'add-to-cart', get_the_ID(), wc_get_cart_url() ) ), esc_html__( 'Buy now', 'woocommerce' ) );
}
$buttons[] = sprintf( $button, get_the_permalink(), esc_html__( 'Read more', 'woocommerce' ) );
return '<p>' . implode( ' ', $buttons ) . '</p>';
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.4.11 | Introduced. |