WC_Embed::product_buttons()

Create the button to go to the product page for embedded products.


Description Description


Return Return

(string)


Top ↑

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>';
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.4.11 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.