WC_Embed::product_buttons
Create the button to go to the product page for embedded products.
Метод класса: WC_Embed{}
Хуков нет.
Возвращает
Строку.
Использование
$result = WC_Embed::product_buttons();
Список изменений
| С версии 2.4.11 | Введена. |
Код WC_Embed::product_buttons() WC Embed::product buttons WC 10.7.0
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>';
}