Skip to content

Instantly share code, notes, and snippets.

View Yorlinq's full-sized avatar
🏠
Working from home

Dennis Dallau Yorlinq

🏠
Working from home
View GitHub Profile
@Yorlinq
Yorlinq / Remove 'Marketing' menu item from admin menu - WooCommerce
Created July 23, 2022 15:32
Remove 'Marketing' menu item from admin menu - WooCommerce
// Remove 'Marketing' menu item from admin menu
add_filter('woocommerce_admin_features', function($features) {
return array_values (
array_filter( $features, function($feature) {
return $feature !== 'marketing';
} )
);
});
@Yorlinq
Yorlinq / Shortcode for 'Shopping cart url' - WooCommerce
Created July 23, 2022 15:29
Shortcode for 'Shopping cart url' - WooCommerce
// 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' );
@Yorlinq
Yorlinq / Shortcode for 'Add to cart url' by 'Product id' - WooCommerce
Created July 23, 2022 15:26
Shortcode for 'Add to cart url' by 'Product id' - WooCommerce
// 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();
}
@Yorlinq
Yorlinq / Shortcode for 'Product image url' by 'Product id' - WooCommerce
Last active July 23, 2022 15:24
Shortcode for 'Product image url' by 'Product id' - WooCommerce
// 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');
@Yorlinq
Yorlinq / Shortcode for 'Product image' by 'Product id' - WooCommerce
Created July 23, 2022 15:17
Shortcode for 'Product image' by 'Product id' - WooCommerce
// 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();
}
@Yorlinq
Yorlinq / Shortcode for 'Product url' by 'Product id' - WooCommerce
Created July 23, 2022 15:15
Shortcode for 'Product url' by 'Product id' - WooCommerce
// 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();
}
@Yorlinq
Yorlinq / Shortcode for 'Product price' by 'Product id' - WooCommerce
Created July 23, 2022 15:11
Shortcode for 'Product price' by 'Product id' - WooCommerce
// 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();
}
@Yorlinq
Yorlinq / Shortcode for 'Current product name' - WooCommerce
Created July 23, 2022 15:08
Shortcode for 'Current product name' - WooCommerce
// 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' );
@Yorlinq
Yorlinq / Shortcode for 'Product description' by 'Product id' - WooCommerce
Created July 23, 2022 13:38
Shortcode for 'Product description' by 'Product id' - WooCommerce
// 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;
}
@Yorlinq
Yorlinq / Shortcode for 'Product name' by 'Product id' - WooCommerce
Last active July 23, 2022 13:36
Shortcode for 'Product name' by 'Product id' - WooCommerce
// 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();
}