This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Shopping cart url': [yl_cart_url] | |
function yl_cart_url_shortcode( $atts ) { | |
return wc_get_cart_url(); | |
} | |
add_shortcode( 'yl_cart_url', 'yl_cart_url_shortcode' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Add to cart url' by 'Product id': [yl_product_add_to_cart id=''] | |
function yl_product_add_to_cart_shortcode($atts) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product($atts['id']); | |
$output = $_product->add_to_cart_url(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product image url' by 'Product id': [yl_product_image_url] id='' | |
function yl_product_image_url_shortcode($atts) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if (intval( $atts['id'] ) > 0 && function_exists('wc_get_product')) { | |
$_product = wc_get_product($atts['id']); | |
$image_id = $_product->get_image_id(); | |
$output = wp_get_attachment_image_url($image_id, 'full'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product image' by 'Product id': [yl_product_image id=''] | |
function yl_product_image_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product( $atts['id'] ); | |
$output = $_product->get_image(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product url' by 'Product id': [yl_product_url id=''] | |
function yl_product_url_shortcode($atts) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product( $atts['id'] ); | |
$output = $_product->get_permalink(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product price' by 'Product id': [yl_product_price id=''] | |
function yl_product_price_shortcode($atts) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product( $atts['id'] ); | |
$output = $_product->get_price_html(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Current product name': [yl_current_product_name] | |
function yl_current_product_name_shortcode() { | |
global $product; | |
$output = get_the_title(); | |
return $output; | |
} | |
add_shortcode( 'yl_current_product_name', 'yl_current_product_name_shortcode' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product description' by 'Product id': [yl_product_short_desciption id=''] | |
function yl_product_short_desciption_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product( $atts['id'] ); | |
$output = $_product->post->post_excerpt; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shortcode for 'Product name' by 'Product id': [yl_product_name id=''] | |
function yl_product_name_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'id' => null, | |
), $atts ); | |
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ | |
$_product = wc_get_product( $atts['id'] ); | |
$output = $_product->get_title(); | |
} |