• DONATE to NULLED!
    Вы можете помочь Форуму и команде, поддержать финансово.
    starwanderer - модератор этого раздела будет Вам благодарен!

Помощь Как выводить Апсейл товары WooCommerce в карточке товара?

mishiko

Постоялец
Регистрация
5 Сен 2011
Сообщения
320
Реакции
135
Есть магазин на WooCommerce свой шаблон стоит не могу вывести Апсейл в карточке товара шаблон карточки выгладит вот так

PHP:
<?php
/**
* The template for displaying product content in the single-product.php template
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see     https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.4.0
*/

defined( 'ABSPATH' ) || exit;

/**
* Hook: woocommerce_before_single_product.
*
* @hooked wc_print_notices - 10
*/

if ( post_password_required() ) {
    echo get_the_password_form(); // WPCS: XSS ok.
    return;
}

wc_print_notices();
?>

мой шаблон в html + ACF

тут должно выводится Апсейл

низ карточки товара html + ACF

Пробовал выводить вот так

PHP:
<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>
    <?php
    /**
     * Hook: woocommerce_after_single_product_summary.
     *
     * @hooked woocommerce_output_product_data_tabs - 10
     * @hooked woocommerce_upsell_display - 15
     * @hooked woocommerce_output_related_products - 20
     */
    do_action( 'woocommerce_after_single_product_summary' );
    ?>
</div>

Выводит только описание

Полностью шаблон content-single-product.php

PHP:
<?php
/**
* The template for displaying product content in the single-product.php template
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see     https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.4.0
*/

defined( 'ABSPATH' ) || exit;

/**
* Hook: woocommerce_before_single_product.
*
* @hooked wc_print_notices - 10
*/

if ( post_password_required() ) {
    echo get_the_password_form(); // WPCS: XSS ok.
    return;
}

wc_print_notices();
?>
  <style>
/*    div.yith-plugin h1, div.product_meta, form.cart, small.woocommerce-price-suffix{
      display: none;
    }
    span.ywcrbp_regular_price >*/
    .cost{
      display: block;
    }
  </style>

    <div class="breadcrumps">
      <div class="wrapper">
        <a href="<?php echo home_url();?>" class="breadcrumps__link">Главная</a>
        <a href="<?php echo home_url();?>/shop/" class="breadcrumps__link">Заказать on-line</a>
        <span class="breadcrumps__page"><?php echo get_the_title();?></span>
      </div>
    </div>

    <div class="delivery wrapper">
      <div class="delivery__item">
        <header class="delivery__header">
          <img src="<?php echo get_template_directory_uri();?>/img/delivery-0.png" alt="Доставка курьером" class="delivery__img">
          <h2 class="delivery__title">Доставка курьером</h2>
        </header>
        <p class="delivery__text">СПб и Москва <span class="cost__now">300 р.</span></p>
        <p class="delivery__text">Другие регионы <span class="cost__now">600 р.</span></p>
      </div>
      <div class="delivery__item">
        <header class="delivery__header">
          <img src="<?php echo get_template_directory_uri();?>/img/delivery-1.png" alt="Доставка почтой" class="delivery__img">
          <h2 class="delivery__title">Доставка почтой</h2>
        </header>
        <p class="delivery__text">Все регионы РФ <span class="cost__now">300 р.</span></p>
      </div>
      <div class="delivery__item">
        <header class="delivery__header">
          <img src="<?php echo get_template_directory_uri();?>/img/delivery-2.png" alt="Бесплатная доставка почтой" class="delivery__img">
          <h2 class="delivery__title">Бесплатная доставка почтой</h2>
          </header>
        <p class="delivery__text">При сумме заказа от <span class="delivery__now">5 500 р.</span></p>
      </div>
      <div class="delivery__item">
        <header class="delivery__header">
          <img src="<?php echo get_template_directory_uri();?>/img/delivery-3.png" alt="Доставка в Казахстан" class="delivery__img">
          <h2 class="delivery__title">Доставка в&nbsp;Казахстан</h2>
        </header>
        <p class="delivery__text">От <span class="delivery__now">1 255 р.</span></p>
        <a href="" class="delivery__link">Дистрибьюторы за рубежом</a>
      </div>
    </div>

    <section class="main-inner wrapper card__outer">
      <aside class="left-menu">
          <ul id="menu-accordion" class="accordionjs">
        
                <?php
  $taxonomy     = 'product_cat';
  $orderby      = 'name';
  $show_count   = 0;
  $pad_counts   = 0;
  $hierarchical = 1;
  $title        = '';
  $empty        = 1;
$args = array(
  'taxonomy'     => $taxonomy,
  'orderby'      => $orderby,
  'show_count'   => $show_count,
  'pad_counts'   => $pad_counts,
  'hierarchical' => $hierarchical,
  'title_li'     => $title,
  'hide_empty'   => $empty
);
?>
<?php $all_categories = get_categories( $args );
//print_r($all_categories);
foreach ($all_categories as $cat) {
    //print_r($cat);
    if($cat->category_parent == 0) {
        $category_id = $cat->term_id;
        $catik = $cat->name;
?>
            <li>
              <div><span><?php echo $cat->name;?></span></div>
              <div>
                <ul class="left-menu__list">
                <?php   $loop = new WP_Query( array(
    'numberposts' => -1,
    'product_cat'    => $cat->slug,
    'post_type'=> 'product',
  
) );

while ( $loop->have_posts() ) : $loop->the_post();
        global $product;?>
                  <li class="left-menu__item">
                    <a href="<?php the_permalink($p->ID);?>" class="left-menu__link left-menu__link_active">
                      <?php echo get_the_title($p->ID);?>
                    </a>
                  </li>
<?php  endwhile;

    wp_reset_query(); ?>
                </ul>
              </div>
            </li>
          
            <?php }    }
?>
          </ul>
      </aside>

      <div class="main-inner__right card"><h1 class="card__title"><?php echo get_the_title();?></h1>
        <div class="card__info">
          <img src="<?php global $product;

$post_thumbnail_id = $product->get_image_id();  if ( $product->get_image_id() ) {
            echo  the_post_thumbnail_url();
        } else { echo wc_placeholder_img_src( 'woocommerce_single' );}?>" alt="Ферменкол Элактин от растяжек" class="card__img" width="370" height="370">
          <div class="card__btns">
            <a href="/gde-kupit/" class="btn card__btn_pharm">
              <img src="<?php echo get_template_directory_uri();?>/img/pharm-icon.png" alt="Аптека" class="card__btn_img">
              Купить в аптеке
            </a>



             <? if ($product->get_sale_price()!='') { ?>
              <div class="cost cost_card">
                <span class="cost__now cost__now_card"><?php
                  if($product->get_sale_price()!='')
                    echo $product->get_sale_price();
                  else
                    echo $product->get_price();?> р.
                </span><?php
                if($product->get_sale_price()!=''){ ?>
                  <span class="cost__before cost__before_card">
                    <?php echo $product->get_regular_price();  ?> р.
                  </span><?php
                } ?>
              </div>
            <? }else{
              do_action( 'woocommerce_single_product_summary' );
            } ?>
<?php if ( get_field( 'pokazania' ) ) : ?>
    <p><strong>Показания:&nbsp;</strong><?php the_field( 'pokazania' ); ?></p>
<?php endif; ?>

          
<ul class="icon__list-sp">
  <li class="red-1 <?php the_field('sposob1'); ?>"><img src="<?php echo get_template_directory_uri();?>/img/red1.jpg" alt="Апликации"><p>Аппликации</p></li>
  <li class="red-2 <?php the_field('sposob2'); ?>"><img src="<?php echo get_template_directory_uri();?>/img/red2.jpg" alt="Фонофорез"><p>Фонофорез</p></li>
  <li class="red-3 <?php the_field('sposob3'); ?>"><img src="<?php echo get_template_directory_uri();?>/img/red3.jpg" alt="Электрофорез"><p>Электрофорез</p></li>
</ul>

<!--  <? do_action( 'woocommerce_single_product_summary' ); ?> -->

<style>
  div.card__btns h1,
  div.quantity,
  table tr.wdr_tr_head,
  table td.wdr_td_body_range,
  button.single_add_to_cart_button,
  div.product_meta,
  h1.product_title.entry-title,
  table td.wdr_td_body_discount{
    display: none;
  }
  table.woo_discount_rules_table{
    margin-bottom: 15px;
  }
  ins, span.woocommerce-Price-amount{
    font-weight: 700;
    color: #991717;
    font-size: 34px;
    text-decoration: none;
  }
  del > span.woocommerce-Price-amount{
    font-size: 26px;
    color: #000;
    margin-right: 10px;
  }
  span.woocommerce-Price-amount:after{
    content: 'р.';
  }
  div.cost.pokup span.woocommerce-Price-amount.amount,
  div.cost.pokup ins{
    font-size: 24px;
  }
  div.cost.pokup del{
    color: black;
  }
  div.cost.pokup del span.woocommerce-Price-amount.amount{
    font-size: 20px;
  }
</style>

            <a href="?add-to-cart=<?php echo $post->ID;?>" class="btn btn-main btn-main_fill card__btn_add">Добавить в корзину</a>
          </div>
        </div>
        <div class="card__tabs">
          <ul class="card-tabs__list">
            <li class="card-tabs__btn card-tabs__btn_active" data-tab="1">Описание</li>
           <?php if(get_field('product_how')!=''){?> <li class="card-tabs__btn" data-tab="2">Способ применения</li> <?php } ?>
            <?php if(get_field('product_how2')!=''){?><li class="card-tabs__btn" data-tab="3">Инструкция</li> <?php } ?>
            <li class="card-tabs__btn" data-tab="4">Отзывы</li>
          </ul>
          <div class="card-tabs__cont">
            <div class="card-tabs__info" data-tab="1">
              <?php the_content(); ?>
              </div>
          <?php if(get_field('product_how')!=''){?>  <div class="card-tabs__info" data-tab="2">
              <?php echo get_field('product_how');?>
            </div>
             <?php } ?>
          <?php if(get_field('product_how2')!=''){?>  <div class="card-tabs__info" data-tab="3">
<?php echo get_field('product_how2');?>            </div>
          <?php } ?>
            <div class="card-tabs__info" data-tab="4">
              <?php comments_template(); ?>
            </div>
          </div>          
        </div>
      </div>
    </section>




    Тут должен быть Апсейл




    <?php dynamic_sidebar( 'recommended' ); ?>
    <section class="often-order">
      <div class="wrapper">
        <h2 class="when-from__title">С этим товаром часто заказывают</h2>
        <div class="choose__items">
        <?php   $loop = new WP_Query( array(
    'posts_per_page' => 4,
    'post_type'=> 'product',
  
) );

while ( $loop->have_posts() ) : $loop->the_post();
        global $product;?>
                
                    <div class="choose__item">
                    <a href="<?php the_permalink();?>">
            <h3 class="choose-item__title"><?php echo get_the_title();?></h3>
            <img src="<?php echo  the_post_thumbnail_url(); ?>" alt="Ферменкол Элактин" class="choose-item__img" width="232" height="232">
            <div class="cost pokup">
<!--               <span class="cost__now"><?php if($product->get_sale_price()!='') echo $product->get_sale_price(); else echo $product->get_price();?> р.</span>
               <?php  if($product->get_sale_price()!=''){?> <span class="cost__before"><?php echo $product->get_regular_price();  ?> р.</span><?php } ?> -->
           <? do_action( 'woocommerce_single_product_summary' ); ?>
            
            </div>
            <a href="?add-to-cart=<?php echo $post->ID;?>" class="btn btn-main btn-main_fill choose__btn">Добавить в корзину</a>
            </a>
          </div>
<?php  endwhile;

    wp_reset_query(); ?>
      
        
        </div>
      </div>
    </section>
  
  <!-- Способы доставки и оплаты -->
    <section class="way-delivery wrapper">
      <h2 class="when-from__title"><?php the_field('title-dev', 'option'); ?></h2>
      <p class="way-delivery__text">
        <?php the_field('desc-dev', 'option'); ?>
      </p>
      <p class="way-delivery__text">
        <?php the_field('sub-dev', 'option'); ?>
      </p>
      <div class="table__outer">
        <?php the_field('tab-dev', 'option'); ?>
      </div>
      <p class="way-delivery__footer"><?php the_field('prim-dev', 'option'); ?></p>
    </section>
    <!--END Способы доставки и оплаты -->
  
    <!-- Способы оплаты -->
    <section class="way-pay">
      <div class="wrapper way-pay__wrapper">
        <img src="<?php echo get_template_directory_uri();?>/img/pay.png" alt="pay" class="way-pay__img">
        <div class="way-pay__info">
          <h2 class="way-pay__title"><?php the_field('title-pay', 'option'); ?></h2>
          <?php if( have_rows('punkt-pay', 'option') ): ?>
          <ul class="way-pay__list">
            <?php while( have_rows('punkt-pay', 'option') ): the_row(); ?>
            <li class="way-pay__item">
              <?php the_sub_field('punkts'); ?>
            </li>
            <?php endwhile; ?>
          </ul>
          <?php endif; ?>
        </div>
      </div>
    </section>
    <!-- END Способы оплаты -->

    <!-- Инфо блоки -->
    <section class="when">
      <?php if( have_rows('block3-dop', 'option') ): ?>
      <div class="when__wrapper when__wrapper_inner">
        <div class="wrapper when__items">
        <?php while( have_rows('block3-dop', 'option') ): the_row(); ?>
          <figure class="when__item">
            <div class="when-items__img">
              <img src="<?php the_sub_field('img'); ?>" alt="<?php the_sub_field('title'); ?>">
            </div>
            <figcaption class="when__info">
              <h3 class="when-items__title"><?php the_sub_field('title'); ?></h3>
              <p class="when-items__text"><?php the_sub_field('desc'); ?></p>
            </figcaption>
          </figure>
        <?php endwhile;?>
        </div>
      </div>
      <?php else : endif; ?>
    </section>
    <!-- END Инфо блоки -->
  
    <!-- Эффект от применения -->
    <section class="effect">
      <div class="wrapper effect__wrapper">
        <div class="effect__info">
          <h2 class="effect__title">
            <?php the_field('title-e-dop', 'option'); ?>
          </h2>
          <img src="<?php echo get_template_directory_uri();?>/img/effect-mob.jpg" alt="Эффект от применения" class="section-img-mobile" width="320" height="284">
          <p class="effect__text">
            <?php the_field('desx-e-dop', 'option'); ?>
          </p>
          <?php if( have_rows('punkt-e-dop', 'option') ):?>
          <ul class="effect__list">
          <?php while ( have_rows('punkt-e-dop', 'option') ) : the_row();?>
            <li class="effect__item"><?php the_sub_field('p'); ?></li>
          <?php endwhile;?>
          </ul>
          <?php else : endif; ?>
        </div>
        <img src="<?php echo get_template_directory_uri();?>/img/effect.jpg" alt="Эффект от применения" class="effect__img" width="592">
      </div>
    </section>
    <!-- END Эффект от применения -->
  
    <!-- Доктора -->
    <section class="doctor">
      <div class="owl-carousel">
      <?php if( have_rows('block-doc-dop', 'option') ):?>
        <?php while ( have_rows('block-doc-dop', 'option') ) : the_row();?>
        <div class="doctor__wrapper">
          <div class="doctor__info">
            <h2 class="doctor__title">
              <?php the_sub_field('ifo'); ?>
            </h2>
            <p class="doctor__subtitle">
              <?php the_sub_field('special'); ?>
            </p>
            <blockquote class="doctor__text">
              <?php the_sub_field('viskaz'); ?>
            </blockquote>
          </div>
          <img src="<?php the_sub_field('img'); ?>" alt="<?php the_sub_field('ifo'); ?>" class="doctor__img" width="592" height="405">
        </div>
        <?php endwhile;?>
      <?php else : endif; ?>
      </div>
    </section>
    <!-- END Доктора -->
 
Назад
Сверху