0

尝试将“添加到愿望清单”添加到编码中,以便它显示在类别页面上。因此,类别字段中显示的每个产品都会有自己单独的“添加到愿望清单”按钮。我也将把它复制到搜索方法中,因为我的很多类别实际上都是搜索。我正在开发的网站有很多类似的产品,而且主要是视觉效果,所以它真的会派上用场。

我为 ADD TO WISHLIST 准备的当前代码是(省略了 CSS - 无需让任何人感到厌烦!):

<a class="wish_add" href="<?php echo $add_to_wishlist[$j]['add']; ?>" title="<?php echo $button_to_wishlist; ?>" rel="nofollow"><span><?php echo $button_to_wishlist; ?>+ Favorites</span></a>

整个页面的代码是(CATEGORY.TPL):

<div class="clear">&nbsp;</div><!--[if lt IE 7]><br /><![endif]-->
    <?php if (!$categories && !$products) { ?>
    <div class="content"><?php echo $text_error; ?></div>
    <?php } ?>
    <?php
  if($_SERVER['QUERY_STRING']!='_route_=ketubahs'){
  ?>
    <!--<?php /* if ($categories) { */ ?> -->
    <?php if ($categories && $heading_title!="Scroll Down to View All Our Ketubahs on One Page") { ?>
    <table class="listC" cellspacing="7">
      <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) {
       $numpages=sizeof($products);
      ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td width="25%"><?php if (isset($categories[$j])) { ?>
          <a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="margin-bottom: 3px;" /></a><br />
          <a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>
          <?php } ?></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </table>
    <?php } 
                                                   }
    ?>
    <?php if ($products) { ?>
 <!-- <div class="sort"> -->
      <div class="sort" <?php if ($heading_title=="Scroll Down to View All Our Ketubahs on One Page") { echo "style='margin-top:-40px;'"; } ?> >
      <div class="div1">
        <select name="sort" onchange="location = this.value">
          <?php foreach ($sorts as $sorts) { ?>
          <?php if (($sort . '-' . $order) == $sorts['value']) { ?>
          <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
          <?php } else { ?>
          <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
          <?php } ?>
          <?php } ?>
        </select>
      </div>
      <div class="div2"><?php echo $text_sort; ?></div>
    </div>
    <table class="listC" cellspacing="7">
      <?php for ($i = 0; $i < sizeof($products); $i = $i + 4) {
       $numpages=sizeof($products);
      ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td width="25%">
<?php if (isset($products[$j])) { ?>
              <a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" width="210px" height="210px" /></a><br /><Br />
          <div style="margin-top:-15px;"><a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
<?php       if($products[$j]['artist'] != 'Rosenthal, Gary' and $products[$j]['artist'] != 'Jessy Judaica' and !empty($products[$j]['artist'])){
            $artist_fname=substr($products[$j]['artist'],strpos($products[$j]['artist'],",")+1);
            $artist_lname=substr($products[$j]['artist'],0,strpos($products[$j]['artist'],","));
        $artist_fullname=trim($artist_fname)." ".trim($artist_lname);
        if (trim($products[$j]['artist'])=="Zeev") {
        $artist_fullname="Ze&#39;ev"; }
        if (trim($products[$j]['artist'])=="This is not a Ketubah") {
        $artist_fullname="This is not a Ketubah"; }
        $artistname=str_replace(' ','-',$artist_fullname);
        if (trim($artistname)=="Ze&#39;ev") {
        $artistname="Ze-ev"; }
        if (trim($artistname)=="This is not a Ketubah") {
        $artistname="This is not a Ketubah"; }
        $artist_path='meet-our-artists/'.strtolower($artistname);
 ?>
          <a href="<?php echo $artist_path; ?>"><span style="color:#FFF;font-weight:200;"><?php echo $artist_fullname; ?></span></a><br />
<?php } else { ?>
          <span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
<?php } ?>
          <?php if ($display_price) { ?>
          <?php if (!$products[$j]['special']) { ?>
          <span style="color: #00d8ff; font-weight: bold;cursor:default;"><?php echo $products[$j]['price']; ?></span>
          <?php } else { ?>
          <span style="color: #00d8ff; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #FAA; font-weight: bold;"><?php echo $products[$j]['special']; ?></span>
          <?php } ?>
</div>
          <?php } ?>
          <br />
          <?php if ($products[$j]['rating']) { ?>
          <img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
          <?php } ?>
          <?php } ?>

        <a class="wish_add" href="<?php echo $add_to_wishlist[$j]['add']; ?>" title="<?php echo $button_to_wishlist; ?>" rel="nofollow"><span><?php echo $button_to_wishlist; ?>+ Favorites</span></a>
          <a class="cart_add" href="<?php echo $products[$j]['add']; ?>" title="<?php echo $button_add_to_cart; ?>" ><span><?php echo $button_add_to_cart; ?></span></a>

          </td>
        <?php } ?>
      </tr>
      <?php } ?>

    </table>
    <div class="pagination" style="width:950px;text-align:right"><?php
    if (($numpages-$ii)>1) {
     echo "Displaying all ".($numpages-$ii)." items in this category.";
     } else {
     echo "Displaying 1 item in this category.";
     } ?></div>
         <?php } ?>



  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<?php echo $footer; ?> 

任何帮助都会很棒!

干杯

股份公司

4

1 回答 1

0

想通了。控制器中有一个禁用的功能阻止按钮投入生产:

位于 Controller/category/category.php

$this->data['add_to_wishlist'] = HTTPS_SERVER . 'index.php?route=product/wishlist&p=' . $result['product_id'];

一旦启用,它就会为 Opencart 提供其余的愿望清单代码,允许我放置愿望清单并将其添加到类别页面中每个产品的购物车:

位于 view/category/category.php

<a href="<?php echo $add_to_wishlist; ?>" class="wish_add" rel="nofollow"><span><?php echo  $button_to_wishlist; ?>+ Favorites</span></a>
于 2012-06-28T16:46:05.973 回答