Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    Join Date
    Apr 2008
    Posts
    24
    Plugin Contributions
    0

    cart error shoppingcart contents to be viewed on header

    Hi

    guys i have added this code in "my_template/common/tpl_header.php"

    PHP Code:
      <table width="95%" border="1" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC">
      
      <?php
      
    foreach($productArray as $product)
      {
      
    $proName=$product['productsName'];
      
    $proPriceEach=$product['productsPriceEach'];
      
    $proImg=$product['productsImage'];
      
    $proQty=$product['showFixedQuantityAmount'];
      
    $proAttribs=$product['attributes'];
      
    ?>
      <tr>
              <td colspan="5"><?php echo $proName;?></td>
      </tr>

      <tr>
          <td rowspan="2" id="balloonProImg">
        <?php 
        $src
    =htmlentities($proImg,ENT_NOQUOTES);
        
    $s explode(" "$src);
        
    $s =explode ("=",$s[1]);
        
    $img$s[1];
        
    $pat '/(^"+|"+$)/';
        
    $imgWOQ=preg_replace$pat''$img );
        
    $imgWH getimagesize($imgWOQ);
        
    $percent=0.10;//10%
        
    $width=round($imgWH[0]*$percent);
        
    $height=round($imgWH[1]*$percent);
        echo 
    "<img src=\"$imgWOQ\" width=\"$width\" height=\"$height\"/>";
        
    ?> 
        </td>
        <td>Qty</td>
        <td>Color</td>
        <td>Size</td>
        <td>Total</td>
      </tr>
      
      <tr>
        <td><?php echo $proQty;?></td>
        <?php 
        $count
    =count($proAttribs);
        for(
    $i=1$i<=$count$i++)
            {
                
    $allAttribs=$proAttribs[$i];
                
    //print_r($indProduct);
                
    $productOption=$allAttribs[products_options_name];
                
    $productVal=$allAttribs[products_options_values_name];
                
    //echo $productVal;
                
    echo "<td >$productVal</td>";
            }
        
    ?>
      <td><?php echo $proPriceEach?></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <?php
      
    }
      
    ?>
      </table>
    this code display all the items in the cart in a table but
    i cannot view its output on any of the pages. For example when i click home i cant see this table in header and same is the case with other pages. i can only see this table output in header when i click on shopping cart.

    i want to display this table in header all the time regardless of the page user is viewing just like the logo in header displays all the time.

    is it about overriding any thing? i am confused on this.
    can any one suggest any thing.

    salman

  2. #12
    Join Date
    Apr 2008
    Posts
    24
    Plugin Contributions
    0

    Default Re: shoppingcart contents to be viewed on header

    Hi

    the simplist solution is to pass this productArray to $_session array in

    tpl_shopping_cart_default.php
    $_SESSION['tip']=$productArray;

    in tpl_header.php
    if($_SESSION['tip']=='')
    {
    echo 'Your Shopping Bag is Empty';
    }
    else
    {
    $tempProduct=$_SESSION['tip'];
    }

    i am not sure if its safest of the ways but it works
    and solves ur problem of not able to see the actual contents of the cart when u r on other pages then cart page its self.

    hope this can invite some other people to this thread for sharing their ideas

    regards
    salman

  3. #13
    Join Date
    Apr 2008
    Posts
    24
    Plugin Contributions
    0

    Default Final solution

    hi got it working now

    do these changes in following files

    add this code to header_php.php
    in here
    zen\includes\modules\pages\shopping_cart
    afte line 162 with in the loop.
    PHP Code:
    $_SESSION['tip'][$i] = array('attributeHiddenField'=>$attributeHiddenField,
                                
    'flagStockCheck'=>$flagStockCheck,
                                
    'flagShowFixedQuantity'=>$showFixedQuantity,
                                
    'linkProductsImage'=>$linkProductsImage,
                                
    'linkProductsName'=>$linkProductsName,
                                
    'productsImage'=>$productsImage,
                                
    'productsName'=>$productsName,
                                
    'showFixedQuantity'=>$showFixedQuantity,
                                
    'showFixedQuantityAmount'=>$showFixedQuantityAmount,
                                
    'showMinUnits'=>$showMinUnits,
                                
    'quantityField'=>$quantityField,
                                
    'buttonUpdate'=>$buttonUpdate,
                                
    'productsPrice'=>$productsPrice,
                                
    'productsPriceEach'=>$productsPriceEach,
                                
    'rowClass'=>$rowClass,
                                
    'buttonDelete'=>$buttonDelete,
                                
    'checkBoxDelete'=>$checkBoxDelete,
                                
    'id'=>$products[$i]['id'],
                                
    'attributes'=>$attrArray); 
    by adding this code you will have whole product array in your session array and you can access this any where in the cart.

    now you have to access this array in header so in tpl_header.php
    zen\includes\templates\your_template_directory\common
    if this file is not here then copy one from defalut template directory and create a common folder in your template diretory paste it in there and you can access this whole array there like this
    PHP Code:
    $tempProduct=$_SESSION['tip'];
    foreach($tempProduct as $product)
      {
      $proName=$product['productsName'];
      $proPriceEach=$product['productsPriceEach'];
      $proImg=$product['productsImage'];
      $proQty=$product['showFixedQuantityAmount'];
      $proAttribs=$product['attributes'];
      ?>
      <tr>
              <td colspan="5"><?php echo $proName;?></td>
      </tr>

      <tr>
          <td rowspan="2" id="balloonProImg">
        <?php 
        $src
    =htmlentities($proImg,ENT_NOQUOTES);
        
    $s explode(" "$src);
        
    $s =explode ("=",$s[1]);
        
    $img$s[1];
        
    $pat '/(^"+|"+$)/';
        
    $imgWOQ=preg_replace$pat''$img );
        
    $imgWH getimagesize($imgWOQ);
        
    $percent=0.10;//10%
        
    $width=round($imgWH[0]*$percent);
        
    $height=round($imgWH[1]*$percent);
        echo 
    "<img src=\"$imgWOQ\" width=\"$width\" height=\"$height\"/>";
        
    ?> 
        </td>
        <td>Qty</td>
        <td>Color</td>
        <td>Size</td>
        <td>Total</td>
      </tr>
      
      <tr>
        <td><?php echo $proQty;?></td>
        <?php 
        $count
    =count($proAttribs);
        for(
    $i=1$i<=$count$i++)
            {
                
    $allAttribs=$proAttribs[$i];
                
    //print_r($indProduct);
                
    $productOption=$allAttribs[products_options_name];
                
    $productVal=$allAttribs[products_options_values_name];
                
    //echo $productVal;
                
    echo "<td >$productVal</td>";
            }
        
    ?>
      <td><?php echo $proPriceEach?></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <?php
      
    }
      
    ?>
      </table>
    and this is my code of tooltip


    <script type="text/javascript">

    new Tip('bag',$('divText'), {
    title : 'Your Shopping Bag Has</br><strong><?php echo sizeof($_SESSION['cart']->get_products()); ?>&nbsp;</strong>&nbsp;Item(s)&nbsp;&nbsp;<?php echo $currencies->format($_SESSION['cart']->show_total());?> ',
    //ajax: { url: 'includes/templates/template_default/sideboxes/tpl_shopping_cart.php', options: { onComplete: function(transport) {/*write your code*/} } },
    style:'darkgrey',
    hideOn: { element: '.close', event: 'click'},
    closeButton: true,
    hook: { target: 'topMiddle', tip: 'bottomRight' },
    stem: 'topRight',
    offset: { x: -7, y: 135 }
    });
    </script>
    for this you will need to read
    http://www.nickstakenburg.com/projects/prototip2/

    now as you are adding products to $_SESSION array and able to view it in virtually any where, what about if any product is deleted form shoppingcart then if wont refresh the $_SESSION array so for this you need an other change
    in
    zen\includes\classes
    PHP Code:
    after line no.553 after the if condition but in the remove fucntion
    foreach ( $_SESSION['tip'] as $key => $value )
        {    
            if ( 
    in_array$products_id$value) ) 
            {       
            unset( 
    $_SESSION['tip'][$key] );  
            echo 
    'unseted//';  
            }
        } 
    after this you will have a session arry $_SESSION['tip'] array which updates it self with all the changes.

    ok guys this method works for me you can change it for you need
    it might have any problem but non that i am aware of

    hope this help any one out there

    regards
    salman sadiq

  4. #14
    Join Date
    Jul 2008
    Posts
    1
    Plugin Contributions
    0

    Default Re: Showing cart items

    for this you will need to read
    http://www.nickstakenburg.com/projects/prototip2/

    now as you are adding products to $_SESSION array and able to view it in virtually any where, what about if any product is deleted form shoppingcart then if wont refresh the $_SESSION array so for this you need an other change
    in
    zen\includes\classes
    PHP Code:
    after line no.553 after the if condition but in the remove fucntion
    foreach ( $_SESSION['tip'] as $key => $value )
    {
    if ( in_array( $products_id, $value) )
    {
    unset( $_SESSION['tip'][$key] );
    echo 'unseted//';
    }
    }

    would like to do this on my site, tried following your instructions.... are you talking about the shopping_cart.php in classes folder?

    also im new to zen, where would i be injecting the javascript code? im pretty sure the *.js goes in the templates/yourtemplate/jscript folder but the script you have... where does that go

    if im just dumb you can tell me too.... along with the answer

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 3
    Last Post: 2 Aug 2016, 01:03 PM
  2. v139h Deleting items from shopping cart--error showing
    By DarkAngel in forum General Questions
    Replies: 4
    Last Post: 23 Apr 2013, 05:10 AM
  3. New Items / View All Items: Only showing first letter of product description
    By opengrave in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 22 Feb 2011, 07:57 PM
  4. Shopping Cart not showing up after adding items
    By russa2 in forum General Questions
    Replies: 3
    Last Post: 30 Jan 2009, 03:25 PM
  5. Replies: 4
    Last Post: 14 Dec 2007, 01:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg