add_filter( 'woocommerce_order_item_name', 'add_image_to_review', 10, 3 );
function add_image_to_review( $name, $item, $visible ) {
$product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
$link = get_permalink( $product->id );
if(!is_wc_endpoint_url()) {
if(strpos($name, ' - ') !== false){
$name = preg_replace('/-([^-]+$)/', '', $name);
}
return ''. $name .' ';
}
if(is_account_page()){
if(strpos($name, ' - ') !== false){
$name = preg_replace('/-([^-]+$)/', '', $name);
}
}
if(is_account_page() || is_checkout()){
$thumbnail = $product->get_image();
$image = '' . $thumbnail . ' ';
return $image . ''. $name .' ';
}
return ''. $name .' ';
}add_action( 'add_meta_boxes', 'add_replacement_box' );
function add_replacement_box(){
add_meta_box( 'has_replacement', __('Náhradní plnění','woocommerce'), 'has_replacement_check', 'shop_order', 'side', 'core' );
}
function has_replacement_check(){
global $post;
if(get_post_meta( $post->ID, 'has_replacement', true ) === 'yes'){
echo '
Požaduje náhradní plnění
';
} else if(get_post_meta( $post->ID, 'has_replacement', true ) === 'no'){
echo 'Nepožaduje náhradní plnění
';
}
}add_filter('woocommerce_available_variation', 'add_price_if_equal', 10, 3);
function add_price_if_equal($available, $variable, $variation){
if (empty($available['price_html'])) {
$available['price_html'] = '' . $variation->get_price_html() . ' ';
}
return $available;
}add_filter('views_edit-product', function ($views) {
$views['variation_pending'] = sprintf(
'Varianty čekají na schválení (%d)',
isset($_GET['variation_pending']) ? 'class="current"' : '',
count(pp_get_variations_pending_products()),
);
unset($views['pillar_content']);
return $views;
}, 10, 1);
function pp_get_variations_pending_products()
{
global $wpdb;
return $wpdb->get_col(
"SELECT p.ID
FROM $wpdb->posts p
INNER JOIN $wpdb->posts v ON v.post_parent = p.ID
WHERE p.post_type = 'product' AND v.post_type = 'product_variation' AND v.post_status = 'private'"
);
}
add_action('load-edit.php', function () {
global $typenow;
if ('product' !== $typenow) {
return;
}
add_filter('posts_where', function ($where) {
if (!empty($_GET['variation_pending'])) {
$where .= sprintf(' AND ID IN (%s)', implode(',', pp_get_variations_pending_products()));
}
return $where;
});
});add_action( 'woocommerce_after_cart_item_name', function($cart_item) {
echo '' . $cart_item['data']?->get_sku() . ' ';
}, 10, 1 );function renderBadges($class = '') {
global $product, $wpdb;
if (empty($product)) {
return;
}
$show_grouped = get_post_meta( $product->get_id(), 'show_grouped', true );
if ($product->get_catalog_visibility() === 'hidden' && $show_grouped == 1) {
return;
}
$instock = false;
if ($product->is_type('variable')) {
// Get variation IDs
$variation_ids = $product->get_children();
if (!empty($variation_ids)) {
// Prepare the array of IDs for the query
$variation_ids_placeholder = implode(',', array_map('absint', $variation_ids));
// Using direct SQL query that matches the structure you provided
$sql = $wpdb->prepare(
"SELECT ID
FROM {$wpdb->posts}
INNER JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)
WHERE 1=1
AND {$wpdb->posts}.ID IN ($variation_ids_placeholder)
AND ({$wpdb->postmeta}.meta_key = '_stock_status'
AND {$wpdb->postmeta}.meta_value != 'outofstock')
AND {$wpdb->posts}.post_type = 'product_variation'
AND {$wpdb->posts}.post_status = 'publish'
GROUP BY {$wpdb->posts}.ID
ORDER BY {$wpdb->posts}.post_date DESC
LIMIT 1"
);
$result = $wpdb->get_var($sql);
$instock = !empty($result);
}
} else {
$instock = $product->is_in_stock();
}
$list = '';
if (has_term('doprava-zdarma', 'product_tag', $product->get_id())) {
$list .= 'Doprava Zdarma ČR ';
}
if (has_term('novinka', 'product_tag', $product->get_id())){
$list .= 'Novinka ';
}
if (has_term('na-zakazku', 'product_tag', $product->get_id())) {
$list .= 'Zakázka ';
}
if (has_term('do-tydne', 'product_tag', $product->get_id())) {
$iden3 = get_post_meta( $product->get_id(), 'iden3_identificator', true );
if ($iden3 === 'DO4') {
$list .= '3-4 týdny ';
$list .= 'Zakázka ';
} elseif ($iden3 === 'DO2') {
$list .= '1-2 týdny ';
} else {
$list .= 'V externím skladu ';
}
}
if (has_term('vyprodej', 'product_tag', $product->get_id())){
$list .= $instock ? 'Výprodej ' : 'Nedostupné ';
}
if (has_term('limitovana-edice', 'product_tag', $product->get_id())){
$list .= $instock ? 'Limitka ' : 'Nedostupné ';
}
if (has_term('skladem', 'product_tag', $product->get_id())){
$list .= $instock ? 'Skladem ' : 'Brzy skladem ';
}
$tags = get_the_terms($product->get_id(), 'product_tag');
$tagsToIgnore = ['doprava-zdarma', 'na-zakazku', 'skladem', 'do-tydne', 'vyprodej', 'novinka', 'limitovana-edice'];
foreach ($tags as $tag) {
if (in_array( $tag->slug, $tagsToIgnore )) {
continue;
}
$list .= '' . $tag->name . ' ';
}
if ($instock && !has_term('do-tydne', 'product_tag', $product->get_id()) && !has_term('skladem', 'product_tag', $product->get_id())) {
$list .= 'Skladem ';
}
$list .= ' ';
echo $list;
}
add_shortcode('generate_badges', function() {
renderBadges('single');
});
add_shortcode('generate_badges_', function() {
renderBadges();
});
add_action('jet-woo-builder/templates/products/after-item-thumbnail', function() {
renderBadges();
});add_action( 'wp_footer', function () {
?>
';
});add_shortcode( 'pp_product_color_sets', function(){
$color_sets_field = get_field( 'color_set');
$color_sets = [];
foreach ($color_sets_field as $field_set) {
$set = $color_sets[$field_set['set_name']] = [];
foreach ($field_set['colors'] as $color) {
$set[$color['color_name']] = $color['color'];
}
}
$color_sets_terms_ids = wp_get_post_terms( get_the_ID(), 'color_set', [ 'fields' => 'ids' ] );
foreach ($color_sets_terms_ids as $id) {
$color_sets_term = get_field( 'Sets', 'color_set_' . $id );
// Merge with existing color sets
foreach ($color_sets_term as $field_set) {
$set_name = $field_set['set_name'];
if (!isset($color_sets[$set_name])) {
$color_sets[$set_name] = [];
}
foreach ($field_set['colors'] as $color) {
$color_name = $color['color_name'];
if (isset($color_sets[$set_name][$color_name])) {
continue;
}
$color_sets[$set_name][$color_name] = $color['color'];
}
}
}
ob_start();
foreach ($color_sets as $set_name => $colors) {
echo '';
echo '
' . $set_name . ': ' . array_key_first($colors) . ' ';
echo '
';
foreach ($colors as $color_name => $color) {
echo '
';
}
echo '
';
}
//JS changer of selected color
echo '';
return ob_get_clean();
} );add_filter( 'woocommerce_cart_shipping_method_full_label', 'custom_shipping_icons', 10, 2 );
function custom_shipping_icons( $label, $method ) {
//
// DPD
//
if( $method->method_id == 'flexible_shipping_single' && $method->instance_id === 13 ) {
$label = ' '.$label.'
DPD doručí balík na Vámi zvolenou adresu.
Doručení DPD si můžete přizpůsobí svým potřebám přímo ve webové aplikaci DPD Kurýr
Dodání následující pracovní den od vyzvednutí
3 pokusy o doručení
Pojištění zásilky do 50 000 Kč v ceně přepravy
Informování SMSkou/e-mailem
';
//
// DPD slovensko
//
} else if( $method->method_id == 'flexible_shipping_single' && $method->instance_id === 14 ) {
$label = ' '.$label;
//
// Ceska posta - do ruky
//
} else if( $method->method_id == 'flat_rate' && $method->instance_id === 4 ) {
$label = ' '.$label;
//
// Ceska posta - na postu
//
} else if( $method->method_id == 'flat_rate' && $method->instance_id === 5 ) {
$label = ' '.$label;
//
// Balikovna
//
} else if( $method->method_id == 'flat_rate' && $method->instance_id === 3 ) {
$label = ' '.$label;
//
// Vyzvednuti na prodejne
//
} else if( $method->method_id == 'local_pickup' ) {
$label = ' '.$label.'Zdarma ';
//
// Zásilkovna
//
} else if( $method->method_id == 'packetery_shipping_method' ) {
$label = ' '.$label;
}
return $label;
}
add_filter( 'woocommerce_gateway_title', 'custom_payment_label', 25, 2 );
function custom_payment_label( $title, $gateway_id ){
if($gateway_id === 'cod')
{
global $WOOCS;
$currencies = $WOOCS->get_currencies();
$eur = $currencies['EUR'];
$codPrice = 36.30;
$currency = get_woocommerce_currency();
$symbol = get_woocommerce_currency_symbol();
if($currency === 'EUR')
$codPrice = $codPrice * $eur['rate'];
$title = ' '.$title.''.number_format($codPrice, 2, '.', ' ').' ';
}
return $title;
}
add_action( 'woocommerce_after_order_object_save', 'remove_html_from_method_title' );
function remove_html_from_method_title( $order ) {
global $WOOCS;
$currencies = $WOOCS->get_currencies();
$eur = $currencies['EUR'];
$codPrice = '36.30';
$codPriceEur = strval( number_format( $codPrice * $eur['rate'], 2, '.', '' ) );
$title = $order->get_payment_method_title();
$title = str_replace( ' ', '', $title );
$title = str_replace( '', '', $title );
$title = str_replace( '', '', $title );
$title = str_replace( '', '', $title );
$title = str_replace( $codPrice, '', $title );
$title = str_replace( $codPriceEur, '', $title );
$title = str_replace( ' ', '', $title );
update_post_meta( $order->get_id(), '_payment_method_title', $title );
}add_action('wp_footer', function () {
?>
Ložní povlečení Vafle bavlna 32131-3 – 2P SERVIS
Přejít k obsahu
Great things are on the horizon
Something big is brewing! Our store is in the works and will be launching soon!
You can`t add more product in compare