Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    30
    Plugin Contributions
    0

    Default [Done v1.3.9] Catalog->special

    It might have been covered before but i did not find it.
    v 1.3.8a
    In Catalog->Special menu, there is an option to select the ID without going to the drop down menu
    The selection is not checked againt Vouchers Certificate, as made in the drop down menu filter
    It not checked against "none cartable" products either


    After next segment of code ended around line 150

    if ($skip_special == false) {
    $sql = "select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$_POST['pre_add_products_id'] . "'";
    $check_special = $db->Execute($sql);
    if ($check_special->RecordCount() > 0) {
    $skip_special = true;
    $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_DUPLICATE, 'caution');
    }
    }

    I added this code as validation

    if ($skip_special == false) {
    $check_special = $db->Execute("select p.products_id
    from " . TABLE_PRODUCTS . " p
    where p.products_model rlike '" . "GIFT" . "' and
    p.products_id ='" . (int)$_POST['pre_add_products_id'] . "'" );

    if ($check_special->RecordCount() > 0) {
    $skip_special = true;
    $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
    }
    }

    if ($skip_special == false) {
    // do not include things that cannot go in the cart
    $check_special = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type= pt.type_id
    where pt.allow_add_to_cart = 'N' and
    p.products_id ='" . (int)$_POST['pre_add_products_id'] . "'" );

    if ($check_special->RecordCount() > 0) {
    $skip_special = true;
    $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
    }
    }

    Second, upon entering pID, if you click cancel, the products remains in the data base special with price zero.
    To avoid that i changed the whole logic behind this procedure.
    Basically, it adds a record into the special data base, to be processed by the action=edit portion of code
    What I did was to disable adding the record, jumping into the action=insert code.
    So rather than using the products array, i used the pID value instead.
    It requires PID name and price, plus the form values passed then to the action=insert code before body.
    I added a 'GET['select']' variable to differentiate standard insert from this.
    It is working so far
    I apologize for my poor php skills but what I did follows


    coomented out next section and modified zen_redirect statement:

    // add empty special
    /*
    $specials_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
    $expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));

    $products_id = zen_db_prepare_input($_POST['pre_add_products_id']);
    $db->Execute("insert into " . TABLE_SPECIALS . "
    (products_id, specials_new_products_price, specials_date_added, expires_date, status, specials_date_available)
    values ('" . (int)$products_id . "',
    '" . zen_db_input($specials_price) . "',
    now(),
    '" . zen_db_input($expires_date) . "', '0', '" . zen_db_input($specials_date_available) . "')");

    $new_special = $db->Execute("select specials_id from " . TABLE_SPECIALS . " where products_id='" . (int)$products_id . "'"); */

    // $messageStack->add_session(SUCCESS_SPECIALS_PRE_ADD, 'success');
    // zen_redirect(zen_href_link(FILENAME_SPECIALS, 'action=edit' . '&sID=' . $new_special->fields['specials_id']));
    zen_redirect(zen_href_link(FILENAME_SPECIALS, 'action=new&select=1' . '&sID=' . $_POST['pre_add_products_id']));
    break;

    then

    after
    <tr> <form name="new_special" <?php
    echo 'action="' . zen_href_link(FILENAME_SPECIALS, zen_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action . "&go_back=" . $_GET['go_back'] , 'NONSSL') . '"';

    ?> method="post"><?php if ($form_action == 'update') echo zen_draw_hidden_field('specials_id', $_GET['sID']); ?>
    <td><br><table border="0" cellspacing="0" cellpadding="2">
    <tr>
    <td class="main"><?php echo TEXT_SPECIALS_PRODUCT?>&nbsp;</td>
    <td class="main"><?php


    i added/modified next piece of code
    if ( $_GET['select'] == '1' ) {
    $again = $db->Execute("select pd.products_name, p.products_price
    from ". TABLE_PRODUCTS_DESCRIPTION . " pd ," . TABLE_PRODUCTS . " p
    where p.products_id = pd.products_id and
    p.products_id = '". $_GET['sID'] . "'");

    echo $again->fields['products_name'] . '['.$again->fields['products_price'] .']';
    echo zen_draw_hidden_field('products_price',zen_get_products_base_price($_GET['sID']));
    echo zen_draw_hidden_field('products_id',$_GET['sID']);

    }
    else
    echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : zen_draw_products_pull_down('products_id', 'size="5" style="font-size:10px"', $specials_array, true, $_GET['add_products_id'], true); echo zen_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : ''));


    I modified the cancel buttom after
    <td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
    <td class="main" align="right" valign="top"><br><?php

    this way ( to prevent a non stardard return screen)
    echo (($form_action == 'insert') ? zen_image_submit('button_insert.gif', IMAGE_INSERT) :
    zen_image_submit('button_update.gif', IMAGE_UPDATE)) . '&nbsp;&nbsp;&nbsp;
    <a href="' . ($_GET['go_back'] == 'ON' ?
    zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $_GET['add_products_id']) :
    zen_href_link(FILENAME_SPECIALS, 'page=' . $_GET['page'] .
    ((isset($_GET['sID']) and $_GET['sID'] != '' and $_GET['select'] != '1') ? '&sID=' . $_GET['sID'] : ''))) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?>
    </td>

    around line 29 in the
    break;
    case 'insert':

    code, i modified next IF line

    if ($_POST['products_id'] < 1 && $_GET['select'] != '1' ) {
    $messageStack->add_session(ERROR_NOTHING_SELECTED, 'caution');
    } else {

    and the item gets added correctly to the specials DB

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Catalog->special

    Good catch ...

    The change I am adding will be lines 134-141 changing to:
    Code:
            if ($skip_special == false) {
              $sql = "select products_id, products_model from " . TABLE_PRODUCTS . " where products_id='" . (int)$_POST['pre_add_products_id'] . "'";
              $check_special = $db->Execute($sql);
              if ($check_special->RecordCount() < 1 || substr($check_special->fields['products_model'], 0, 4) == 'GIFT') {
                $skip_special = true;
                $messageStack->add_session(WARNING_SPECIALS_PRE_ADD_BAD_PRODUCTS_ID, 'caution');
              }
            }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Oct 2007
    Location
    Kentucky - USA
    Posts
    428
    Plugin Contributions
    0

    Default Re: [Done v1.3.9] Catalog->special

    I believe that the file in question is admin/specials.php Correct?

    Sawhorse

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: [Done v1.3.9] Catalog->special

    That is correct ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: [Done v1.3.9] Catalog->special

    I think I still need to check the Cancel on that one ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Replies: 1
    Last Post: 10 Dec 2010, 09:48 PM
  2. Replies: 0
    Last Post: 26 Sep 2008, 06:03 AM
  3. Replies: 1
    Last Post: 6 Jul 2008, 05:32 PM
  4. Replies: 1
    Last Post: 18 Feb 2007, 05:22 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