Jump to content
Sign in to follow this  
newjey

Как логичнее составить условие для вывода блока

Recommended Posts

Всем привет.

Есть вот такой блок в категории товара: 

 <div class="product-thumb">
            <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?> class="img-responsive" /></a></div>
            <div>
              <div class="caption">
             <h4><a style="font-size: 13px;" href="<?php echo $product['href']; ?>"title="<?php echo $product['name_full']; ?>"><?php echo $product['name']; ?></a></h4>
			  <div>
			  <div style="font-size:11px;color:#888;text-align:left;"><?php echo $product['manufacturer']; ?></div>
			 <div style="text-align:right;margin-top:-20px;padding-bottom:5px;"> <?php if ($product['rating']) { ?>
                <div class="rating">
                  <?php for ($i = 1; $i <= 5; $i++) { ?>
                  <?php if ($product['rating'] < $i) { ?>
                  <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
                  <?php } else { ?>
                  <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
                  <?php } ?>
                  <?php } ?>
                </div>
                <?php } ?></div></div>
        
                
                <!--<?php if ($product['price']) { ?>
                <p class="price">
                  <?php if (!$product['special']) { ?>
                  <?php echo $product['price']; ?>
                  <?php } else { ?>
                  <span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
                  <?php } ?>
                  <?php if ($product['tax']) { ?>
                  <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
                  <?php } ?>-->
                </p>
                <?php } ?>
              </div>
              <div class="button-group">
<?php if ($product['price']) { ?>
        <div class="price" style="float: left;">
          <?php if (!$product['special']) { ?>
          <?php echo $product['price']; ?>
          <?php } else { ?>
          <span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
          <?php } ?>
          <?php if ($product['tax']) { ?>
          <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
          <?php } ?>
         
        </div>
        <?php } ?>
        <?php if (isset($product['quantity']) && ($product['quantity'] > 0)) { ?>
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
<?php } else { ?>
<div style="text-align:right;font-weight:600;color:#A3A3A3;padding-top:5px;margin-bottom: 14px;"><?php echo "ПРОДАНО"; ?></div>
<?php } ?>

      </div>
            </div>
          </div>

Мне надо сделать условие проверку, если у товара UPC равно 1 то выводить этот блок в рамочке, то есть:

<div class="product-thumb" style="border: 1px solid red;">

Если UPC пустое поле то выводить по умолчанию 

<div class="product-thumb">

Сначала хотел продублировать весь блок if else, но почему-то подумал что можно как-то проще и логичнее сделать.

Кто знает как подскажите.

Спасибо.

Share this post


Link to post
Share on other sites
<div class="product-thumb" <?php if($product['upc']==1){ ?>style="border: 1px solid red;" <?php } ?>>
  • +1 1

Share this post


Link to post
Share on other sites

Благодарю)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.