Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2010
    Posts
    19
    Plugin Contributions
    0

    Default How to style a php variable??

    Ok, so I have a very picky customer and they wern't simply happy with the standard way zen cart shows the size, quantity and add to cart button. Then needed to have them all in a row and I've managed to track that down to the tpl_product_info_display.php file.

    My problem is that I can't get the add to cart button to float right with a slight amount of top padding to allow it to all line up correctly. I'm really not good with php, which is great for trying to do these advance modifications. So hopefully thats where you guys come in.

    You can take a look at an example of my issue HERE

    I'm pretty sure the issue is in fact in the tpl_product_info_display.php file but have had zippy success so far. Here's the area in the code that I was succesfully able to modify to get the quantity box and add to cart button side by side instead of on top of each other

    Code:
              <?php
        $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
                if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
                  // hide the quantity box and default to 1
                  $the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART . 'style="float:right"', BUTTON_IN_CART_ALT);
                } else {
                  // show the quantity box
        $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
                }
        $display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);
      ?>
      <?php if ($display_qty != '' or $display_button != '') { ?>
        <div id="cartAdd">
        <?php
          echo $display_qty; 
          echo $display_button;
                ?>
              </div>
      <?php } // display qty and button ?>

    If I were able to define an id to the BUTTON_IMAGE_IN_CART variable then I could easily float right and pad.

    Is there an easy way to modify that variable? Help me I'm lost and I can't get paid til I get this last thing done!!!

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: How to style a php variable??

    Quote Originally Posted by DesignLessDesign View Post
    If I were able to define an id to the BUTTON_IMAGE_IN_CART variable then I could easily float right and pad.

    Is there an easy way to modify that variable? Help me I'm lost and I can't get paid til I get this last thing done!!!
    Don't know if this is what you are looking for, but the CONSTANT you are refering to can be found/set here:

    /includes/languages/english/button_names.php
    Line #30 : define('BUTTON_IMAGE_IN_CART', 'button_in_cart.gif');

    The developers toolkit is great for finding this kind of thing.

    Cheers
    Rod

  3. #3
    Join Date
    Mar 2010
    Posts
    19
    Plugin Contributions
    0

    Default Re: How to style a php variable??

    Yea, I've been able to identify all of the places that the button shows up. My issue is that I don't know how to call upon that variable and assign it an html id so that I can use my stylesheet to float it right and pad it down.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to style a php variable??

    That constant doesn't exist in the HTML output that the CSS applies to, but you can address its output as the third consecutive input in #cartAdd.

    Find #cartAdd in your stylesheet and replace the existing rule with
    Code:
    /*Shopping Cart Display*/
    #cartAdd {
        float: right;
        margin: 2.7em 1em -0.8em;
        border: 1px solid #000000;
        padding-top: auto;
        padding-bottom: auto;
        width:300px;
        height:36px;
        }
    #cartAdd input+input+input {
        float: right;
        position: relative;
        bottom: 0.7em;
       }
    Note that this will not work in IE6, as that version is too primitive to recognize adjacent selectors.

  5. #5
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,838
    Plugin Contributions
    31

    Default Re: How to style a php variable??

    #cartAdd input+input+input {
    Well, I'll add that to my very long list of "things I didn't know about CSS", thanks very much.

    I had a similar issue as DesignLessDesign with positioning those items where I wanted and, not knowing the above trick, I added divs and ids to all the items in the template instead.

  6. #6
    Join Date
    Mar 2010
    Posts
    19
    Plugin Contributions
    0

    Default Re: How to style a php variable??

    Thank you so much gjh42. I was fighting with that for over an hour.

 

 

Similar Threads

  1. v153 Base price as a PHP variable
    By Matt Staines in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 21 Mar 2015, 06:50 PM
  2. v151 paypaldp.php: Invalid class variable
    By lat9 in forum Bug Reports
    Replies: 0
    Last Post: 27 May 2013, 07:41 PM
  3. Replies: 1
    Last Post: 8 Feb 2011, 02:07 AM
  4. Replies: 1
    Last Post: 4 Feb 2011, 01:39 AM
  5. actual language php variable ?
    By Franck69 in forum General Questions
    Replies: 2
    Last Post: 18 Jun 2008, 05:34 PM

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