WC_Embed::product_buttons
Create the button to go to the product page for embedded products.
Method of the class: WC_Embed{}
No Hooks.
Returns
String.
Usage
$result = WC_Embed::product_buttons();
Changelog
| Since 2.4.11 | Introduced. |
WC_Embed::product_buttons() WC Embed::product buttons code WC 10.9.4
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( ProductType::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>';
}