Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2021
    Location
    Utah
    Posts
    10
    Plugin Contributions
    0

    Default Customizing old ZC V151 Customized Code

    [I am trying to update a running ZC 151 install to ZC157C that has custom code that adds a field named “pak” to the order_products table. The original discussion about this is still on the forum as “Adding in Product Activation Key”, and also “How to detect if an order has been paid?”
    Between the originator of this code being deceased and some of the ZC internals being reworked, I am struggling.

    The ZC 151 code was added to ..includes/classes/order.php in the function Query to revise the $order_products_query (approx. line 164) to:
    V151
    $orders_products_query = "select orders_products_id, products_id, products_name,
    ………
    products_discount_type_from, pak
    $orders_products = $db->Execute($orders_products_query);

    V157C
    $orders_products_query = "SELECT *
    FROM " . TABLE_ORDERS_PRODUCTS . "
    $orders_products = $db->Execute($orders_products_query);

    Question: It appears that since the added field is in the DB, and fetched in the query, pak doesn’t need to be explicitly named?


    Further down into order.php in the function create_add_products
    V151
    $newPAK = $this->generate_product_key();
    $this->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END');
    $sql_data_array = array('orders_id' => $zf_insert_id,
    'products_id' => zen_get_prid($this->products[$i]['id']),
    ……………………
    'pak' => $newPAK);
    zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

    V157C
    At about line 850 “ $sql_data_array” is created:
    $sql_data_array = array('orders_id' => $zf_insert_id,
    'products_id' => zen_get_prid($this->products[$i]['id']),
    …………………….
    products[$i]['products_mixed_discount_quantity'] );
    zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

    Question: Is it permissible to add the code for updating pak on the DB to the end of the $sql_data_array with statement something like the following?
    $sql_data_array = array('orders_id' => $zf_insert_id,
    …………………….
    products[$i]['products_mixed_discount_quantity'], );
    'pak' => (int)$this->products[$i]['pak’]);
    zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    8,047
    Plugin Contributions
    9

    Default Re: Customizing old ZC V151 Customized Code

    I believe you'll find that the feature is built into the 1.5.7c.

    https://docs.zen-cart.com/user/produ...ds_activating/
    Did you read the posting tips?!?
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free Domain, SSL, and Magic Thumb with Semi-Annual or longer plan.

  3. #3
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,015
    Plugin Contributions
    5

    Default Re: Customizing old ZC V151 Customized Code

    in answer to your first question, yes. there is no need to specify any additional field names when querying the database.

    in answer to your 2nd question, i would start learning the observer/notifier system of ZC. that way you can implement your changes without modifying core code. and i think for what you are trying to do there are plenty of observers to get the job done.

    that is of course assuming the new version of ZC does not do what you want it to do and you want to bring your changes to the new version.

    https://docs.zen-cart.com/dev/code/notifiers/

    best.
    help with WCAG is now here! PM if you want some help with this. (or any ZC issue).
    if you feel so inclined, feel free to send some cake....

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,918
    Plugin Contributions
    108

    Default Re: Customizing old ZC V151 Customized Code

    > Question: It appears that since the added field is in the DB, and fetched in the query, pak doesn’t need to be explicitly named?

    Yes, the new code for the orders class does a select *, so you don't have to add your customizations.

    > Question: Is it permissible to add the code for updating pak on the DB to the end of the $sql_data_array with statement something like the following?

    You can certainly do this or you can create an observer. If you create an observer, you won't have to make changes to the core code in the future; if you change includes/classes/order.php, you'll have to re-apply those changes on every upgrade. It's up to you.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

  5. #5
    Join Date
    Jul 2021
    Location
    Utah
    Posts
    10
    Plugin Contributions
    0

    Default Re: Customizing old ZC V151 Customized Code

    Thank you all for responding to my question regarding updating the custom code that was originally inserted into ZC 1.5.1 in the ../includes/classes/order.php. Trying to modify the ZC 1.5,7C order.php creates errors the resolution of which is way beyond my skills. As generously suggested by contributors, the ZC observer/notifier seems to be the long term answer which I hope to incorporate in the future, meanwhile my immediate need is to upgrade this ZC and get off PHP 5.6 before the ISP forces the issue.
    There is only one product and PayPal Express is the only payment method. I am hopeful that after payment has been made and received that there is a better suited PHP script where I could place the custom code that includes having access to the current order_id and the ability to query and update one new table field in the order_products table. Any suggestions which script would be better suited?
    Thanks in advance.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,918
    Plugin Contributions
    108

    Default Re: Customizing old ZC V151 Customized Code

    I'd suggest placing an ad in the Commercial Help Wanted forum for someone to upgrade your store.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

 

 

Similar Threads

  1. v139h New 2014 USPS customized code for zone.
    By inovermyhead in forum Addon Shipping Modules
    Replies: 5
    Last Post: 2 Feb 2014, 09:02 PM
  2. v139h Strange session issue after customizing the checkout code
    By lpa17 in forum General Questions
    Replies: 0
    Last Post: 11 Apr 2012, 05:23 AM
  3. Customizing Code on Checkout
    By Shandy Elliott in forum General Questions
    Replies: 3
    Last Post: 29 Jul 2010, 08:42 PM
  4. Old code has spaces.
    By godspeed27 in forum Upgrading from 1.3.x to 1.3.9
    Replies: 5
    Last Post: 21 Feb 2007, 05:25 AM
  5. customizing interface and cart code
    By bcamp1973 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 Jun 2006, 06:02 AM

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