Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2010
    Posts
    7
    Plugin Contributions
    0

    help question Reading $_Post variables from checkout_shipping page?

    GOAL
    I wanted to add an additional dropdown to my checkout_shipping, Not a problem it is added to the tpl_checkout_shipping_default.php as a "CUSTOM" edit and it appears on my form fine.

    Goal was to add a dropdown box to page #1 of #3 Cart Checkout screens and create a $_SESSION value after Submit ($_POST value) to hold until the ORDER was ready to write to DB and Add the NEW data also.


    I am LOST and wading in the swamp of: Classes, Pages, etc....

    Seemed the next step after the "tpl" change was Custom 'Page' for (.../header_php.php)!?

    It is my understanding ZC loops back on Page#1 to be sure nothing is missing and then does a REDIRECT to Page#2, Naturally dropping the $_Post values. arrrrrrg!

    I would be happy! to see the $_Session or $_Post, not sure where to put a break.
    <?php Print_r ($_SESSION); die("blahblahblah")?>

    Thought I would set in header_php.php and display On #1 or #2


    If I can learn/trace the $_POST process better, I should be able to just set $_SESSION values as I move from page 1,2, to 3 using the $_SESSION['NEWFIELD'] = $_POST['NEWFIELD'];

    Then a forum message suggested an OBSERVER vs. header_php.php, which would be able to see the $_POST from Page #1 at the correct time??

    But I am not sure of the EventID to watch for??
    $this->notify('????????????????');
    # NOTIFY_HEADER_START_CHECKOUT_SHIPPING
    # NOTIFY_HEADER_END_CHECKOUT_SHIPPING
    # NOTIFY_HEADER_START_CHECKOUT_SHIPPING_ADDRESS
    # NOTIFY_HEADER_END_CHECKOUT_SHIPPING_ADDRESS

    So


    Which way is NORTH??
    I am not even sure any more where or when to do a var_dump??


    Reading Links or Examples would be great direction!

    THanks in advance for the push in correct direction.

    PC

    If it matters I have Zen 1.3.8a Vanilla install.
    I assume the logic would be same for 1.3.9 etc etc.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Reading $_Post variables from checkout_shipping page?

    Quote Originally Posted by pcaliban View Post
    It is my understanding ZC loops back on Page#1 to be sure nothing is missing and then does a REDIRECT to Page#2, Naturally dropping the $_Post values. arrrrrrg!
    Not exactly.
    It doesn't "loop back". It actually submits directly to the same page, and once the input selections are validated, it forwards on to the next page.
    So, if you're adding fields to checkout_shipping, then you'll add your processing of POST inputs to the checkout_shipping page logic, whether that's dumping it into a session var after validating, or whatever.
    .

    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
    Oct 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: Reading $_Post variables from checkout_shipping page?

    Thanks for update.

    I also studied the Forum messages .. where you also noted if I was to do this function with an Observer I would need to make another Class Change?.... (17th March 2010, 11:05 AM )

    http://www.zen-cart.com/forum/showth...light=observer

    You noted a 'change' to the base class.
    /includes/classes/class.base.php

    That worried me enough to avoid implementing this simple change using an observer class to monitor $_Session('Cart') activity notices...

    So I will try the checkout_shipping page logic route first.....

    Sanity Check:
    Without yet testing I will assume a NEW Dropdown field on page 1 of 3 can be processed by checkout_shipping page logic upon Submit.
    So if I catch it there by making a /Custom/page/checkout_shipping/header_php.php page logic setup I should be OK?

    I Liked the Observer Method due the low impact on future client upgrades. just.....Listen for that page activity an react!
    ($zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');)

    This would limit re-coding activity to just the tpl_checkout_shipping_default.php

    Regardless of the code location the process should be the same.
    See the $_Post field from page 1; Push to $_Session to save.
    Upon Order Commitment on page 3(checkout_confirmation/header_php.php); push $_Session value to: Order(array): ->Delivery_Address field.

    I think I have plan and will post Success steps later...
    Thanks
    PC

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Reading $_Post variables from checkout_shipping page?

    Quote Originally Posted by pcaliban View Post
    So if I catch it there by making a /Custom/page/checkout_shipping/header_php.php page logic setup I should be OK?
    There's no such thing as a /Custom/page/anything.

    There are no overrides for the /includes/modules/pages/ folder.
    Just edit the files directly.

    Quote Originally Posted by pcaliban View Post
    I also studied the Forum messages .. where you also noted if I was to do this function with an Observer I would need to make another Class Change?.... (17th March 2010, 11:05 AM )

    http://www.zen-cart.com/forum/showth...light=observer
    That was for v1.3.8. It is not necessary for v1.3.9
    .

    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.

  5. #5
    Join Date
    Oct 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: Reading $_Post variables from checkout_shipping page?

    Sorry for such a basic question, this should be EASY!

    What am I missing???

    Re: ZC cart check process!


    Given the INDEX.PHP Load/build Sequence....
    1. Load application_top.php
    2. Set main language directory
    3. Load all *header_php.php files from includes/modules/pages/PAGE_NAME/
    4. Load html_header.php (this is a common template file)
    5. Load main_template_vars.php (this is a common template file)
    6. Load on_load scripts (page based and site wide)
    7. Load tpl_main_page.php (this is a common template file)
    8. Load application_bottom.php


    Step 1
    Added a Dropdown field to template for Page 1 of 3
    ** tpl_checkout_shipping_default.php**
    Also at same time I set $_SESSION for Dropdown "ID" and Set value to ''
    (yep!, checked to be sure this was created!)
    <?php Print_r ($_SESSION); ?>



    Step 2

    I reviewed the code in the checkout_shipping/Header_php.php
    ** Assume this loaded (Seq#3)in first display of page 1 of 3. Shipping

    I see how the tpl file has a HIDDEN field set to set ACTION and PROCESS
    upon Submit

    In every case I always entered TEXT in COMMENTs FIELD to see on Page 2 of 3
    Payment screen. Just to be sure something was not cached.

    Approx Line#(129 - ZC V1.3.8a)

    // process the selected shipping method
    if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
    if (zen_not_null($_POST['comments'])) {
    $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
    // added code to test location
    $_SESSION['pickuplocations']= 'PUT Test Message 9999 here';

    }
    $comments = $_SESSION['comments'];
    // Change Screen 1 entered data before screen 2 is displayed (after redirect)
    $comments = 'you are empty now';


    If I understand correctly, (duh! guess I don't)



    I see the flow is to Post to self (index.php) with with Parm
    ?main_page=checkout_shipping (OK checking all is OK before Redirect!)

    with a REdirect in checkout_shipping/header_php.php to Page 2 of 3
    (Naturally $_Post is Gone)

    ** zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT (going to Payment 2 of 3)


    I fail to see why I cannot force data into:
    $_SESSION['pickuplocations']
    or MODIFY
    $comments = 'you are empty now';

    yet if I reload browser page 1 and change the comment field it does pass back to page 2 of 3! My code is ignored....

    So for FUN ...
    I put $comments = 'you are empty now';
    just in front of each POTENTIAL redirect!

    No change by the CODE was seen on browser screen.
    IF I fill in the comments FIELD value...on page 1 of 3 it is changed .. and appears on Page 2 of 3.

    It is as IF I never touched the code!??? and Only ZC works??

    arrrrrg!

  6. #6
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Reading $_Post variables from checkout_shipping page?

    Quote Originally Posted by pcaliban View Post
    $_SESSION['pickuplocations']
    Um, all this is just to give a list of store-pickup locations?
    Why not just use the updated module I posted on the forum to allow the existing store-pickup module to offer a pulldown list of pickup locations?

    http://www.zen-cart.com/forum/showthread.php?t=162519
    Last edited by DrByte; 2 Nov 2010 at 08:37 PM. Reason: added link
    .

    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.

  7. #7
    Join Date
    Oct 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: Reading $_Post variables from checkout_shipping page?

    YEP as suggested I did EDIT the PAGE directly in the PAGE FOLDER
    pages/checkout_shipping/header_php.php
    vs.
    Original attempt
    Custom/pages/checkout_shipping/header_php.php

    Same result....
    I will recheck for Cache issue someplace...

    I MUST be
    I have to be in the WRONG checkout_shipping/header_php.php


    At least the TEMPLATE follow the CUSTOM Folder pattern...
    Direct mods to PAGE/Foldername
    Seems that defeats the documentation directions on how to Avoid having the code changes over written...with each upgrade.

    I will retrace my steps....

    Has to be a stupid oversite...!

  8. #8
    Join Date
    Oct 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: Reading $_Post variables from checkout_shipping page?

    Discovery update.

    Thanks to DrByte for the TIP on Modules NOT following the ZC CUSTOM Folder configuration method for ZC code changes without changing the native files. aka CUSTOM folder

    DrByte's Store Pickup Module is Excellent also! Had the Client not wanted a drop down list driven by the Value of the CART ($50) that suggestion would have been perfect!

    As the ZC documentation states; the presence of the folder Classic in folder structure of: Language, Templates, and Modules should allow for a CUSTOM folders. However, Module did not pay attention to new CUSTOM folder. Language and templates did work correctly. DrByte's Tip was the answer!

    My other ODD Issue of not being able to see a field POSTED from the first screen on checkout (1 of 3) seems to be related to the fact the field is a DROPDOWN vs. a straight input field.

    I tested outside of ZC and could see the POSTED value from a Dropdown field, but in ZC. Have not tested posting to SELF as does ZC posting to Index.php?main_page=????? format or other variations. Page1.php POSTING to Page2.php worked in my test.

    I resolved the ZC issue by including a "HIDDEN" field that is changed by a javascript when the Dropdown OnChange event fires.

    The Hidden filed is seen in the $_POST, but still NO "value" of the DropDown selected, which was used to update the Hidden Field.

    Perhaps all self generated by lack of HTML coding

    But all is good in ZVille again...

  9. #9
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Reading $_Post variables from checkout_shipping page?

    Quote Originally Posted by pcaliban View Post
    DrByte's Store Pickup Module is Excellent also! Had the Client not wanted a drop down list driven by the Value of the CART ($50) that suggestion would have been perfect!
    Again, a simple logic alteration within that module to show certain options based on cart content value would have been much easier to code.
    .

    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.

 

 

Similar Threads

  1. v151 How to get the customer country value from checkout_shipping page?
    By kapsolas in forum General Questions
    Replies: 7
    Last Post: 11 Jan 2013, 07:06 PM
  2. v139h what is $_POST['x'] and $_POST['y'] in checkout_confirmation?
    By linjuming in forum General Questions
    Replies: 0
    Last Post: 21 Jul 2012, 04:46 AM
  3. Sending search variables from a non zencart page
    By leest35 in forum General Questions
    Replies: 0
    Last Post: 3 Aug 2010, 11:18 PM
  4. Reading session variables outside of the zencart directory
    By refreshmentshop in forum General Questions
    Replies: 5
    Last Post: 22 Sep 2009, 09:53 AM
  5. How come I can't modify $_POST variables in an observer
    By audleman in forum General Questions
    Replies: 6
    Last Post: 8 Apr 2008, 07:55 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