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
<?php | |
// creating custom woocommerce order by an acf field called custom_product_popularity | |
function leoshop_add_new_postmeta_orderby( $sortby ) { | |
$sortby['custom_popularity'] = __( 'Sortieren nach benutzerdefinierten', 'hello-theme-child'); | |
return $sortby; | |
} | |
add_filter( 'woocommerce_default_catalog_orderby_options', 'leoshop_add_new_postmeta_orderby' ); | |
add_filter( 'woocommerce_catalog_orderby', 'leoshop_add_new_postmeta_orderby' ); | |
function leoshop_add_postmeta_ordering_args( $sort_args ) { |
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
<?php | |
add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 ); | |
function shorten_woo_product_title( $title, $id ) { | |
if (!is_singular(array('product')) && get_post_type($id) === 'product') { | |
// return substr( $title, 0, 30) . '…'; // change last number to the number of characters you want | |
return wp_trim_words($title, 4); // last number = words | |
} else { | |
return $title; | |
} | |
} |
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
<?php | |
add_action('woocommerce_after_shop_loop_item_title', 'add_custom_product_info', 18); | |
function add_custom_product_info() { | |
global $product; | |
$product_unit_price = get_field('unit_price', $product->id); | |
// Displaying the custom field only when is set with a value | |
if(!empty($product_unit_price )) { | |
// Change text-domain with your own. | |
echo '<p style="color: red; font-weight: 600; font-size: 1.2rem">' . __('Ab ', 'text-domain') . $product_unit_price . '€ / Stück</p>'; | |
} |
OlderNewer