Content single product
<?php
add_filter('woocommerce_reset_variations_link', '__return_empty_string');
add_filter( 'woocommerce_get_stock_html', '__return_empty_string' );
add_action('woocommerce_after_single_product_summary', function() {
global $product;
ob_start();
echo '<div class="col-lg-7">';
if($product->has_attributes() || $product->has_dimensions() || $product->has_weight()):
echo '<h3>' . __('Specificaties', 'suiteseven') . '</h3>';
wc_display_product_attributes($product);
endif;
if(get_post()->post_content):
echo '<h3>' . __('Productomschrijving', 'suiteseven') . '</h3>';
echo nl2br(str_replace('<h2>'.get_the_title().'</h2>', '', get_the_content()));
endif;
$youtube_urls = wc_get_product_terms($product->get_id(), 'pa_youtube-embed-url', 'name');
if(!empty($youtube_urls)) {
foreach($youtube_urls as $youtube_url) {
if(!preg_match('/\/|,/i', $youtube_url->name)) {
?>
<div class="youtube-iframe my-2">
<iframe width="560" height="315"
src="https://www.youtube.com/embed/<?= $youtube_url->name; ?>"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
</div>
<?php
}
}
}
if($yt_id = get_field('youtube_link', get_the_ID())) {
echo '<div class="youtube-iframe my-2">';
echo preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i","<iframe width=\"620\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>",$yt_id);
echo '</div>';
}
if(have_rows('documents', get_the_ID())):
echo '<h3>' . __('Documenten', 'suiteseven') . '</h3>';
if(have_rows('documents', get_the_ID())):
echo '<div class="mb-4">';
while(have_rows('documents', get_the_ID())): the_row();
echo '<a href="' . get_sub_field('document')['url'] . '" target="_blank" class="btn btn--primary mt-2">' . (get_sub_field('name') ?: get_sub_field('document')['title']) . '</a><br>';
endwhile;
echo '</div>';
endif;
endif;
echo '</div>';
$html = ob_get_clean();
echo $html;
}, 15);
add_filter( 'woocommerce_quantity_input_args', function($args, $product) {
if(is_product()) {
$args['max_value'] = 1;
}
return $args;
}, 10, 2 );
add_action('woocommerce_product_thumbnails', function() {
global $product;
$brand = wc_get_product_terms($product->get_id(), 'pa_merk', 'name');
if(!empty($brand)) {
$brand = $brand[0];
if($brand_image = get_field('logo', $brand)) {
ob_start();
wc_get_template(
'suite7/product-image-brand.php',
array(
'product' => $product,
'image' => $brand_image,
)
);
$html = ob_get_clean();
echo $html;
}
}
}, 999);