Jump to content

Archived

This topic is now archived and is closed to further replies.

fatum112

Need help with mysql update quiry..

Recommended Posts

Hi,

i'm trying to make a mambo virtuemart mod,
i'm currently trying to make a script so i can update the product quantety, subtotal, and total price..

i need this all in one..

the current script without any update function is:

[code] <?php
  $dbt = new ps_DB;
  $qt  = "SELECT product_quantity,order_item_name,order_item_sku,product_id,product_item_price,product_final_price, product_attribute
FROM `#__{vm}_order_item`
WHERE #__{vm}_order_item.order_id='$order_id' ";
  $dbt->query($qt);
  $i = 0;
 
  while ($dbt->next_record()){
if ($i++ % 2)
  $bgcolor=SEARCH_COLOR_1;
else
  $bgcolor=SEARCH_COLOR_2;
$t = $dbt->f("product_quantity") * $dbt->f("product_final_price");

  ?>
  <tr bgcolor="<?php echo $bgcolor; ?>" valign="top">
<td width="5%"> <?php $dbt->p("product_quantity") ?></td>
<td width="42%"><?php $dbt->p("order_item_name");
  echo "<br /><font size=\"-2\">" . ps_product::getDescriptionWithTax($dbt->f("product_attribute")) . "</font>";
  ?>
</td>
<td width="9%"><?php  $dbt->p("order_item_sku") ?>&nbsp;</td>
<td width="12%" align="right"><?php
echo $CURRENCY_DISPLAY->getFullValue($dbt->f("product_item_price"), 5); 

?></td>
<td width="12%" align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($dbt->f("product_final_price"));  ?></td>
<td width="19%" align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($t); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  </tr>
  <?php
  }
  ?>
  <tr>
<td colspan="6">&nbsp; </td>
  </tr>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong> <?php echo $VM_LANG->_PHPSHOP_ORDER_PRINT_SUBTOTAL ?>: </strong></div></td>
<td width="19%"><div align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($db->f("order_subtotal"), 5); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
  </tr>
  <?php
  /* COUPON DISCOUNT */
$coupon_discount = $db->f("coupon_discount");

 
if( PAYMENT_DISCOUNT_BEFORE == '1') {
  if ($db->f("order_discount") != 0) {
  ?>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div  align="right"><strong><?php
  if( $db->f("order_discount") > 0)
echo $VM_LANG->_PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT;
  else
echo $VM_LANG->_PHPSHOP_FEE;
?>:</div></strong></td>
<td width="19%"><div  align="right"><?php
  if ($db->f("order_discount") > 0 )
echo "-" . $CURRENCY_DISPLAY->getFullValue(abs($db->f("order_discount")));
elseif ($db->f("order_discount") < 0 )
echo "+" . $CURRENCY_DISPLAY->getFullValue(abs($db->f("order_discount"))); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  </td>
  </tr>
 
  <?php
  }
  if( $coupon_discount > 0 || $coupon_discount < 0) {
  ?>
  <tr>
<td colspan="5"><div align="right"><?php echo $VM_LANG->_PHPSHOP_COUPON_DISCOUNT ?>:</div>
</td>
<td><div align="right"><?php
  echo "- ".$CURRENCY_DISPLAY->getFullValue( $coupon_discount ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
</td>
  </tr>
  <?php
  }
}
  ?>
 
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_ORDER_PRINT_TOTAL_TAX ?>: </div></strong></td>
<td width="19%"><div align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($db->f("order_tax")) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
  </tr>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_ORDER_PRINT_SHIPPING ?>: </div></strong></td>
<td width="19%"><div align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($db->f("order_shipping")) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
  </tr>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_ORDER_PRINT_SHIPPING_TAX ?>: </div></strong></td>
<td width="19%"><div align="right"><?php echo $CURRENCY_DISPLAY->getFullValue($db->f("order_shipping_tax")) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
  </tr>
  <?php
if( PAYMENT_DISCOUNT_BEFORE != '1') {
  if ($db->f("order_discount") != 0) {
  ?>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php
  if( $db->f("order_discount") > 0)
echo $VM_LANG->_PHPSHOP_PAYMENT_METHOD_LIST_DISCOUNT;
  else
echo $VM_LANG->_PHPSHOP_FEE;
?>:</strong></div></td>
<td width="19%"><div align="right"><?php
  if ($db->f("order_discount") > 0 )
echo "-" . $CURRENCY_DISPLAY->getFullValue(abs($db->f("order_discount")));
elseif ($db->f("order_discount") < 0 )
echo "+" . $CURRENCY_DISPLAY->getFullValue(abs($db->f("order_discount"))); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
  </td>
  </tr>
 
  <?php
  }
  if( $coupon_discount > 0 || $coupon_discount < 0) {
  ?>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_COUPON_DISCOUNT ?>:</div></strong>
</td>
<td><div align="right"><?php
  echo "- ".$CURRENCY_DISPLAY->getFullValue( $coupon_discount ); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
</td>
  </tr>
  <?php
  }
}
  ?>
  <tr>
<td width="5%">&nbsp;</td>
<td width="42%">&nbsp;</td>
<td colspan="3"><div align="right"><strong><?php echo $VM_LANG->_PHPSHOP_CART_TOTAL ?>:</div> </strong></td>
<td width="19%"><div align="right"><strong><?php echo $CURRENCY_DISPLAY->getFullValue($db->f("order_total")); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></strong>
  </td>[/code]


now i need to make a script to update the quantety, total price and subtotal all at once to the database,
anyone a idea?
(PS: for anyone that helps will be placed in the copyright file when the full mod is released.)

Regards,
Marco

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.