Jump to content



Latest News: (loading..)

- - - - -

Checkbox, MySQL ENTRY "true/false" to become "1/0"

order editor 2.3.1

  • Please log in to reply
3 replies to this topic

#1   OSC-Sevilla

OSC-Sevilla
  • Members
  • 391 posts
  • Real Name:George
  • Gender:Male
  • Location:Sevilla, Spain

Posted 04 July 2012 - 02:08 PM

I am modding  order editor to incoporate my lead time addon that shows if the product carries a lead time and how many days, during editing the order the operatoer can change these the specs:

this piece of code refers to a checkbox that shows which product(s) have lead times

    <td class="dataTableContent" valign="top"><input type="checkbox" title="Lead time Active: <?php echo $order->products[$i]['lead_time_days']; ?> DAYS" name="<?php echo "update_products[" . $orders_products_id . "][lead_time]"; ?>" <?php if (ORDER_EDITOR_USE_AJAX == 'true') { ?>onclick="updateProductsField('update', '<?php echo $orders_products_id; ?>', 'products_lead_time', this.checked, this)"<?php } ?> <?php if($order->products[$i]['lead_time']=='1'){ echo "checked=\"true\""; }?>"></td>


The problem i am having is the data form the check box enters mySQL as " true " or " false" - is is all well and good but i would like it to go in as "1" or "0"

My db is currently VARCHAR (5).


I ahve googled searched high and low but not found a straight forward solution.

Any ideas folks??
OSC 2.3.1
INSTALLED:Document Manager / Monthly Sales and Tax Returns / Batch Print Invoices / Ultimate HTML EMAILs / AJAX Attribute Manager / OSC PDF Catalog / Move Bookmarks / Sort Order / Easy Populate / Sales Reports / Low Stock Report / Admin: Model # on Category / Product Administration Screen / Mini images in admin / SLiCK reCaptcha / Google + / Beautiful Breadcrumbs / 2.3.1 - Banner Language Mod / ADD New Page / EASY MAP (google) v.3.0 / Who's Online Enhancement for 2.3.1 / Admin Notes / scrambled order number / remove_unused_images / Quantity Select / Unit Weight / Product Specifions (filter results) / AJAX Product Attributes/ Attribute Codes/ Date & Order No. to Invoice/ O.P.I. 2.0 / Attribute Images / Manual Order Editor / Attributes Clone / Order Editor / Create Order / Company VAT No. / Add customer/  CKEditor 2.3.1 / Page Manager / Default images via admin / Percentage Shipping Price / QTPro / Scroll to Top / PDF Invoice / Featured Products / Product Listing Enhancements / AutoBackups /  Ultimate SEO URLS 5 Pro / Kiss Tags/ ..Custom Admin Mods /

#2   dailce

dailce
  • Members
  • 519 posts
  • Real Name:Ilchy
  • Gender:Male

Posted 04 July 2012 - 02:35 PM

I can't really figure it out with that code, but look for the code that actually enters the data into the database.  You should be able to find where it is actually being updated and simply do a check.  If active == true, then insert 1, else insert 0.  Like this:

$somevariable  = (activeleadtime == true ?  1  : 0);

#3   OSC-Sevilla

OSC-Sevilla
  • Members
  • 391 posts
  • Real Name:George
  • Gender:Male
  • Location:Sevilla, Spain

Posted 05 July 2012 - 08:19 AM

I have used HFT string find tool and not been able to find out the above: but the below is where its going in:

is it possible to add a string above to handle the conversion???




// Update orders_products Table
$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET
products_model = '" . $products_details['model'] . "',
products_name = '" . oe_html_quotes($products_details['name']) . "',
products_price = '" . $products_details['price'] . "',
final_price = '" . $products_details['final_price'] . "',
products_tax = '" . $products_details['tax'] . "',
products_quantity = '" . $products_details['qty'] . "',
   products_lead_time = '" . $products_details['lead_time'] . "',
products_lead_time_days = '" . $products_details['lead_time_days'] . "'
WHERE orders_id = '" . (int)$oID . "'
AND orders_products_id = '$orders_products_id';";
tep_db_query($Query);

Edited by OSC-Sevilla, 05 July 2012 - 08:29 AM.

OSC 2.3.1
INSTALLED:Document Manager / Monthly Sales and Tax Returns / Batch Print Invoices / Ultimate HTML EMAILs / AJAX Attribute Manager / OSC PDF Catalog / Move Bookmarks / Sort Order / Easy Populate / Sales Reports / Low Stock Report / Admin: Model # on Category / Product Administration Screen / Mini images in admin / SLiCK reCaptcha / Google + / Beautiful Breadcrumbs / 2.3.1 - Banner Language Mod / ADD New Page / EASY MAP (google) v.3.0 / Who's Online Enhancement for 2.3.1 / Admin Notes / scrambled order number / remove_unused_images / Quantity Select / Unit Weight / Product Specifions (filter results) / AJAX Product Attributes/ Attribute Codes/ Date & Order No. to Invoice/ O.P.I. 2.0 / Attribute Images / Manual Order Editor / Attributes Clone / Order Editor / Create Order / Company VAT No. / Add customer/  CKEditor 2.3.1 / Page Manager / Default images via admin / Percentage Shipping Price / QTPro / Scroll to Top / PDF Invoice / Featured Products / Product Listing Enhancements / AutoBackups /  Ultimate SEO URLS 5 Pro / Kiss Tags/ ..Custom Admin Mods /

#4   OSC-Sevilla

OSC-Sevilla
  • Members
  • 391 posts
  • Real Name:George
  • Gender:Male
  • Location:Sevilla, Spain

Posted 05 July 2012 - 10:56 AM

SOLVED - botched but solved  

       //not deleted=> updated
                      if ($products_details['lead_time']== ('on'||'true')){$products_lead_time = 1;}else {$products_lead_time = 0;};
    // Update orders_products Table
         $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET
                    products_model = '" . $products_details['model'] . "',
                    products_name = '" . oe_html_quotes($products_details['name']) . "',
                    products_price = '" . $products_details['price'] . "',
                    final_price = '" . $products_details['final_price'] . "',
                    products_tax = '" . $products_details['tax'] . "',
                    products_quantity = '" . $products_details['qty'] . "',
                    products_lead_time = '" . $products_lead_time . "',
                    products_lead_time_days = '" . $products_details['lead_time_days'] . "'
                    WHERE orders_id = '" . (int)$oID . "'
                    AND orders_products_id = '$orders_products_id';";
                tep_db_query($Query);
OSC 2.3.1
INSTALLED:Document Manager / Monthly Sales and Tax Returns / Batch Print Invoices / Ultimate HTML EMAILs / AJAX Attribute Manager / OSC PDF Catalog / Move Bookmarks / Sort Order / Easy Populate / Sales Reports / Low Stock Report / Admin: Model # on Category / Product Administration Screen / Mini images in admin / SLiCK reCaptcha / Google + / Beautiful Breadcrumbs / 2.3.1 - Banner Language Mod / ADD New Page / EASY MAP (google) v.3.0 / Who's Online Enhancement for 2.3.1 / Admin Notes / scrambled order number / remove_unused_images / Quantity Select / Unit Weight / Product Specifions (filter results) / AJAX Product Attributes/ Attribute Codes/ Date & Order No. to Invoice/ O.P.I. 2.0 / Attribute Images / Manual Order Editor / Attributes Clone / Order Editor / Create Order / Company VAT No. / Add customer/  CKEditor 2.3.1 / Page Manager / Default images via admin / Percentage Shipping Price / QTPro / Scroll to Top / PDF Invoice / Featured Products / Product Listing Enhancements / AutoBackups /  Ultimate SEO URLS 5 Pro / Kiss Tags/ ..Custom Admin Mods /