Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2016
    Location
    Philippines
    Posts
    6
    Plugin Contributions
    0

    Default Adding custom data to $SESSION['cart']

    ZC Version: 1.5.5a
    PHP version: 7.0
    MySQL version: 5.5.54-cll
    Template: responsive_classic
    Plugins:
    Tabbed Products Pro v1.20
    Zen Colorbox
    Additional Image Swapper
    and
    some self created shipping & payment modules specific to my locale

    The end result I want to achieve:

    Each product has an associated "Point Value" (PV). I want to...
    1) See that PV listed on the "View Cart" page
    2) See the "Total PV" for all items ordered
    3) Record the per item PV into the "orders_products" table
    4) Record the "Total PV" in the "orders" table.

    What I have done to date (successfully)...
    1) Added the field "products_point_value" to the "products" table
    2) Added the ability to add/edit the value per product in my back office
    3) Show the product PV on the shop product listing and detail pages (only if the user is logged in)

    Where I am at now...
    1) Added table column (with associated language definitions) to the "view cart" page (includes/templates/responsive_classic/templates/tpl_shopping_cart_default.php) headings along with Qty, Item Name, Unit & Total
    Code:
    <th scope="col" id="scUnitPointValue"><?php echo TABLE_HEADING_POINT_VALUE; ?></th>
    2) Added table column to display the PV on the "view cart" page (includes/templates/responsive_classic/templates/tpl_shopping_cart_default.php)
    Code:
    <td class="cartUnitDisplay"><?php if ( $detect->isMobile() && !$detect->isTablet() || $_SESSION['layoutType'] == 'mobile' or $detect->isTablet() || $_SESSION['layoutType'] == 'tablet' ) {echo '<b class="hide">' . TABLE_HEADING_POINT_VALUE . ':&nbsp;&nbsp;</b>'; } ?><?php echo $product['productsPointValue']; ?></td>
    3) Added
    Code:
    $productsPointValue = $products[$i]['products_point_value'];
    under
    Code:
    $productsPriceTotal = $currencies->format($ppt) ...
    to the file (includes/modules/pages/shopping_cart/header_php.php) around line 152
    4) Added
    Code:
    'productsPointValue'=>$productsPointValue,
    to the "productArray" above "productsPrice" in the file (includes/modules/pages/shopping_cart/header_php.php) around line 170
    5) Added the field "order_total_point_value" to the table "orders"
    6) Added the field "products_point_value" to the table "orders_products"

    What I don't know...
    1) Where is the db query that gets the per product data to be added to the cart? I think I need to add "products_point_value" to that select statement in order to get it's value
    2) I believe #3 & 4 (above) will add the PV to the session cart array once the select statement is updated. Or am I incorrect?
    3) Then I need to figure out how to have the per product PV totaled and displayed.

    I can't move forward to submitting the order (checkout process) until I can successfully have these "PV" values (per product and total) added to the cart array and displayed on the "view cart" page.

    I hope someone can point me in the right direction.

    Cheers,
    John

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Adding custom data to $SESSION['cart']

    /includes/classes/shopping_cart.php
    line 1206 - after this line add your custom field to the query, followed by a comma
    Code:
                                      p.product_is_free, p.products_priced_by_attribute,
    line 1376 - duplicate this and add your custom field
    Code:
                                      'product_is_free' => $products->fields['product_is_free'],
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2016
    Location
    Philippines
    Posts
    6
    Plugin Contributions
    0

    Default Re: Adding custom data to $SESSION['cart']

    Thank you so much DrByte. Worked like a charm. :)

    Now to tackle totaling the PV for all items in the cart, storing that total in the array and displaying it to the customer.

    Off-Topic... is there a timeframe for the ability to "override" files in the YOUR-Admin_DIRECTORY ?

    Cheers, John

 

 

Similar Threads

  1. v139h Adding custom data to search results
    By DigitalShadow in forum Templates, Stylesheets, Page Layout
    Replies: 12
    Last Post: 7 Oct 2013, 12:49 PM
  2. v150 404 Error when adding to cart (session related)
    By Matt H in forum Bug Reports
    Replies: 9
    Last Post: 30 Dec 2012, 07:16 PM
  3. accessing session data in a custom file
    By skyhigh in forum General Questions
    Replies: 1
    Last Post: 21 Jul 2010, 06:10 PM
  4. Replies: 3
    Last Post: 16 May 2009, 10:53 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR