2016-09-16 2 views
0

Ich versuche, ein Pop-up für Produkt zu erstellen, aber ich bin nicht einmal in der Lage, das Objekt in der Warnmeldung zu sehen: Ich habe definiert $ new_date = date ('md-Y ', $ dt); in einem anderen DivErstellen Sie ein Pop-up mit PHP Variable

Code:

<script> 
    $(document).ready(function(){ 
     $('.pre-sale-product').on('click', function(){ 
      $('.productcart').addClass('pre-sale-item-included'); 
     }); 
     $('.productcart').on('click', function(){ 
      if($(this).hasClass('pre-sale-item-included')){ 
       alert('this.$new_date'); 
       //tried alert(".$new_date."); 
      } 
     }); 
    }) 
    </script> 

Auch ich will ein Pop-up statt Alarm erstellen:

wie diese
<script> 
$(document).ready(function(){ 
    $('.pre-sale-product').on('click', function(){ 
     $('.productcart').addClass('pre-sale-item-included'); 
    }); 
    $('.productcart').on('click', function(){ 
     if($(this).hasClass('pre-sale-item-included')){ 
      <class="productcart" data-toggle="modal" data-target="#myModal_product">Open Modal</button> 

    <!-- Modal --> 
    <div class="modal fade" id="myModal_product" role="dialog"> 
    <div class="modal-dialog"> 

     <!-- Modal content--> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
      <h4 class="modal-title">Modal Header</h4> 
     </div> 
     <div class="modal-body"> 
      <p>Some text in the modal.</p> 
     </div> 
     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 
     </div> 

    </div> 
    </div> 
     } 
    }); 
}) 
</script> 

etwas, aber ich weiß nicht Fehler in der Konsole erhalten, noch es funktioniert ...

Actual .tpl Datei

  <script> 
     $(document).ready(function(){ 
      $('.pre-sale-product').on('click', function(){ 
       $('.productcart').addClass('pre-sale-item-included'); 
      }); 
      $('.productcart').on('click', function(){ 
       if($(this).hasClass('pre-sale-item-included')){ 
        alert('this <?php echo $new_date?>'); 
       } 
      }); 
     }) 
     </script> 

    <div class="thumbnails grid row list-inline"> 
     <?php 
     $icount = 0; 
     foreach ($products as $product) { 
      $item = array(); 
      $item['image'] = $product['thumb']['thumb_html']; 
      $item['title'] = $product['name']; 
      $item['description'] = $product['model']; 
      $item['rating'] = ($product['rating']) ? "<img src='" . $this->templateResource('/image/stars_' . $product['rating'] . '.png') . "' alt='" . $product['stars'] . "' />" : ''; 

      $item['info_url'] = $product['href']; 
      $item['buy_url'] = $product['add']; 

      $preSaleImg = ''; 
      $expectedShippingDate = ''; 
      $newPriceClass = ''; 
      $preSaleClass = ''; 
      if($product['date_available'] > date('Y-m-d')){ 
       $preSaleImg = "<img src='" . $this->templateResource('/image/pre-sale.png') . "' class='pre-sale-img'>"; 
       $dt = strtotime($product['date_available']); 
       $new_date = date('m-d-Y', $dt); 
       $expectedShippingDate = "<span class='expected-shipping-date'>expected shipping date " . $new_date . " </span>"; 
       $newPriceClass = "price-with-expected-shipping-date"; 
       $preSaleClass = 'pre-sale-product'; 
      } 
      if (!$display_price) { 
       $item['price'] = ''; 
      } 

      $review = $button_write; 
      if ($item['rating']) { 
       $review = $item['rating']; 
      } 
      if($icount == 4) { 
       $icount = 0; 
     ?> 
       <div class="clearfix"></div> 
     <?php 
      } 
      $icount++; 
     ?> 
      <div class="col-md-3 col-sm-6 col-xs-6"> 
       <div class="fixed_wrapper"> 
        <div class="fixed"> 
         <a class="prdocutname" href="<?php echo $item['info_url'] ?>" 
          title="<?php echo $item['title'] ?>"><?php echo $item['title'] ?></a> 
         <?php echo $this->getHookvar('product_listing_name_'.$product['product_id']);?> 
        </div> 
       </div> 
       <div class="thumbnail"> 
        <?php if ($product['special']) { ?> 
         <span class="sale tooltip-test"><?php echo $text_sale_label; ?></span> 
        <?php } ?> 
        <?php if ($product['new_product']) { ?> 
         <span class="new tooltip-test"><?php echo $text_new_label; ?></span> 
        <?php } ?> 
        <?php echo $preSaleImg; ?> 
        <a href="<?php echo $item['info_url'] ?>"><?php echo $item['image'] ?></a> 


        <div class="blurb"><?php echo $product['blurb'] ?></div> 
        <?php echo $this->getHookvar('product_listing_details0_'.$product['product_id']);?> 
        <?php if ($display_price) { ?> 
         <div class="pricetag jumbotron"> 
          <span class="spiral"></span> 
          <?php if($product['call_to_order']){ ?> 
           <a data-id="<?php echo $product['product_id'] ?>" href="#" 
             class="btn call_to_order"><?php echo $text_call_to_order?>&nbsp;&nbsp;<i class="fa fa-phone"></i></a> 
          <?php } else if ($product['track_stock'] && !$product['in_stock']) { ?> 
           <span class="nostock"><?php echo $product['no_stock_text']; ?></span> 
          <?php } else { ?> 
           <a data-id="<?php echo $product['product_id'] ?>" 
                  href="<?php echo $item['buy_url'] ?>" 
                  class="productcart <?php echo $preSaleClass; ?>"><?php echo $button_add_to_cart ?></a> 
          <?php } ?> 
          <div class="price"> 
           <?php if ($product['special']) { ?> 
            <div class="pricenew"><?php echo $product['special'] ?></div> 
            <div class="priceold"><?php echo $product['price'] ?></div> 
           <?php } else { ?> 
            <div class="oneprice <?php echo $newPriceClass; ?>"><?php echo $expectedShippingDate; ?><span class='aslowas' style="font-size:12px;">AS LOW AS: </span><?php echo $product['price'] ?></div> 
           <?php } ?> 
          </div> 
          <?php echo $this->getHookvar('product_listing_details1_'.$product['product_id']);?> 
         </div> 
        <?php } ?> 
       </div> 
      </div> 
     <?php 
     } 
     ?> 
    </div> 

<div class="thumbnails list row"> 
    <?php 
    foreach ($products as $product) { 
     $item = array(); 
     $item['image'] = $product['thumb']['thumb_html']; 
     $item['title'] = $product['name']; 
     $item['rating'] = ($product['rating']) ? "<img src='" . $this->templateResource('/image/stars_' . $product['rating'] . '.png') . "' alt='" . $product['stars'] . "' />" : ''; 

     $item['info_url'] = $product['href']; 
     $item['buy_url'] = $product['add']; 
     if (!$display_price) { 
      $item['price'] = ''; 
     } 

     $review = $button_write; 
     if ($item['rating']) { 
      $review = $item['rating']; 
     } 

     ?> 
     <div> 
      <div class="thumbnail"> 
       <div class="row"> 
        <div class="col-md-4"> 
         <?php if ($product['special']) { ?> 
          <span class="sale tooltip-test"><?php echo $text_sale_label; ?></span> 
         <?php } ?> 
         <?php if ($product['new_product']) { ?> 
          <span class="new tooltip-test"><?php echo $text_new_label; ?></span> 
         <?php } ?> 
         <?php echo $this->getHookvar('product_listing_label_'.$product['product_id']);?> 
         <a href="<?php echo $item['info_url'] ?>"><?php echo $item['image'] ?></a> 
        </div> 
        <div class="col-md-8"> 
         <a class="prdocutname" href="<?php echo $item['info_url'] ?>"><?php echo $item['title'] ?> 
          <?php echo $product['model'] ? "(".$product['model'].")" :''; ?></a> 
         <div class="productdiscrption"><?php echo $product['description'] ?></div> 

         <div class="blurb"><?php echo $product['blurb'] ?></div> 
         <?php echo $this->getHookvar('product_listing_details00_'.$product['product_id']);?> 
         <?php if ($display_price) { ?> 
         <div class="pricetag pull-right"> 
          <span class="spiral"></span> 

          <?php if($product['call_to_order']){ ?> 
           <a data-id="<?php echo $product['product_id'] ?>" href="#" 
             class="btn call_to_order"><?php echo $text_call_to_order?>&nbsp;&nbsp;<i class="fa fa-phone"></i></a> 
          <?php } else if ($product['track_stock'] && !$product['in_stock']) { ?> 
           <span class="nostock"><?php echo $product['no_stock_text']; ?></span> 
          <?php } else { ?> 
           <a data-id="<?php echo $product['product_id'] ?>" 
                  href="<?php echo $item['buy_url'] ?>" 
                  class="productcart"><?php echo $button_add_to_cart ?></a> 
          <?php } ?> 


          <div class="price"> 
           <?php if ($product['special']) { ?> 
            <div class="pricenew"><?php echo $product['special'] ?></div> 
            <div class="priceold"><?php echo $product['price'] ?></div> 
           <?php } else { ?> 
            <div class="oneprice"><?php echo $product['price'] ?></div> 
           <?php } ?> 
          </div> 
         </div> 
         <?php } ?> 
         <?php echo $this->getHookvar('product_listing_details11_'.$product['product_id']);?> 
        </div> 

       </div> 
      </div> 
     </div> 
    <?php 
    } 
    ?> 
</div> 

-Code für modal am unteren Rande der TPL-Datei

<script> 
$(document).ready(function(){ 
    $('.pre-sale-product').on('click', function(){ 
     $('.productcart').addClass('pre-sale-item-included'); 
    }); 
    $('.productcart').on('click', function(){ 
     if($(this).hasClass('pre-sale-item-included')){ 
      <class="productcart" data-toggle="modal" data-target="#myModal_product">Open Modal</button> 

    <!-- Modal --> 
    <div class="modal fade" id="myModal_product" role="dialog"> 
    <div class="modal-dialog"> 

     <!-- Modal content--> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal">&times;</button> 
      <h4 class="modal-title">Modal Header</h4> 
     </div> 
     <div class="modal-body"> 
      <p>Some text in the modal.</p> 
     </div> 
     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 
     </div> 

    </div> 
    </div> 
     } 
    }); 
}) 
</script> 
+0

Sie brauchen eine js variabel machen NEW_DATE kein php ein – nogad

+0

Wie kann ich dies ausdrücklich tun ?. Ich benutze es in einem PHP-Skript – Raul

Antwort

0

ich $new_date denke, ist ein PHP-Variable, nicht wahr? Wenn es wahr ist, müssen Sie es mit PHP aussprechen. Versuchen Sie folgendes:

alert('this <?php echo $new_date?>'); 
+0

Versucht dies. Es zeigt nur Eigentlich ist dies nicht die Voraussetzung Ich möchte nur Datum angezeigt werden – Raul

+0

Kannst du den PHP-Code zeigen, wo Sie $ new_date zuweisen, bitte –

+0

Bitte Siehe das Update in meiner Frage – Raul

Verwandte Themen