remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_custom_add_to_cart', 30 );
function woocommerce_custom_add_to_cart() {
if( is_product() ) {
global $product;
$id = $product->get_id();
// Получаем кастом ссылку например из ACF
$custom link = get_field('custom link', $id);
}
?>
<?php if ( is_product() ) : ?>
<a href="<?php echo esc_url( $custom link ) ?>" class="some-custom-btn-class"><?php esc_html_e('Надпись кнопки', 'your_textdomain') ?></a>
<?php endif; ?>
<?php }
if ( ! function_exists( 'add_catalog_additional_description' ) ) {
function add_catalog_additional_description() {
echo 'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Consectetur quo facilis obcaecati perspiciatis! Incidunt reprehenderit obcaecati eveniet amet eaque, cum voluptates rerum velit perferendis, veniam hic, beatae modi temporibus nesciunt.';
}
}
add_action( 'woocommerce_after_shop_loop', 'add_catalog_additional_description', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
if ( ! function_exists( 'single_add_to_cart_wrapper_start' ) ) {
function single_add_to_cart_wrapper_start() {
?>
<div class="product_footer">
<?php
}
}
if ( ! function_exists( 'single_add_to_cart_wrapper_end' ) ) {
function single_add_to_cart_wrapper_end() {
?>
</div>
<?php
}
}
add_action( 'woocommerce_after_single_product_summary', 'single_add_to_cart_wrapper_start', 1 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_add_to_cart', 3 );
add_action( 'woocommerce_after_single_product_summary', 'single_add_to_cart_wrapper_end', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
if ( ! function_exists( 'single_add_to_cart_in_footer' ) ) {
function single_add_to_cart_in_footer() {
?>
<div class="product_footer">
<?php woocommerce_template_single_add_to_cart(); ?>
</div>
<?php
}
}
add_action( 'woocommerce_after_single_product_summary', 'single_add_to_cart_in_footer', 5 );
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
[products tag="hoodie"]
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_show_product_cat', 30 );
function custom_show_product_cat() {
global $product;
echo wc_get_product_category_list( $product->get_id(), ', ', '<div class="product-cat">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</div>' );
}
// Move WooCommerce subcategory list items into heir own <ul> separate from the product <ul>
add_action( 'init', 'move_subcat_lis' );
function move_subcat_lis() {
// Remove the subcat <li>s from the old location.
remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );
add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 40 );
add_action( 'woocommerce_before_shop_loop', 'msc_maybe_show_product_subcategories', 50 );
add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 60 );
}
//Conditonally start the product loop with a <ul> contaner if subcats exist.
function msc_product_loop_start() {
$subcategories = woocommerce_maybe_show_product_subcategories();
if ( $subcategories ) {
echo '<ul class="archive-category-wrapper">';
}
}
//Print the subcat <li>s in our new location.
function msc_maybe_show_product_subcategories() {
echo woocommerce_maybe_show_product_subcategories();
}
//Conditonally end the product loop with a </ul> if subcats exist.
function msc_product_loop_end() {
$subcategories = woocommerce_maybe_show_product_subcategories();
if ( $subcategories ) {
echo '</ul>';
}
}