rodney 2007-07-26 14:54
I need to have an item automatically added to the cart when someone orders something. I have a charge that applieds to every order and I would like for it to be added atumatically when they go to the cart.
» Quick.Cart v2.x 2007-07-26 17:24
Maybe it will help: http://opensolution.org/Quick.Cart/forum/?p=readTopic&nr=3811
rodney 2007-07-29 23:27
Can you send me a new orders.php with the code that you mention above already added. I get errors when I try to add the code. Thanks
rodney 2007-08-01 02:44
Do you think you can send me the orders.php with the code included? Rodney
merci 2007-08-01 08:29
rodney - sorry, but we don't send ready solutions, modyficated code and so on, we only give you tips how to do this.
rodney 2007-08-02 04:02
The following is the error message I get when I add the code from topic 3811. PHP Parse error: syntax error, unexpected '[' in E:\Spirit_New\QCart\actions_client\orders.php on line 38 See Code Below: <?php require_once DIR_CORE.'couriers-'.DB_TYPE.'.php'; require_once DIR_CORE.'couriers.php'; require_once DIR_CORE.'orders-'.DB_TYPE.'.php'; require_once DIR_CORE.'orders.php'; require_once DIR_CORE.'products-'.DB_TYPE.'.php'; require_once DIR_CORE.'products.php'; if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) && !empty( $_COOKIE['sOrderQC_'.LANGUAGE] ) ){ $aOrder = throwOrderMd5( $_COOKIE['sOrderQC_'.LANGUAGE] ); if( isset( $aOrder ) && is_array( $aOrder ) ) $_SESSION['iOrderSession_'.LANGUAGE] = $aOrder[0]; setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 ); } if( $a == 'Basket' ){ if( isset( $sOption ) ){ if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) ) $iOrder = $_SESSION['iOrderSession_'.LANGUAGE]; else{ $_SESSION['iOrderSession_'.LANGUAGE] = $iOrder = throwOrderIdTemp( ); } if( $sOption == 'add' ){ if( isset( $iProduct ) && is_numeric( $iProduct ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity >= 1 ){ addOrderProduct( $iProduct, $iQuantity, $iOrder ); } header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' ); exit; } elseif( $sOption == 'defined' ){ $aProductsToAdd[] = Array( 2, 1 ); $aProductsToAdd[] = Array( 3, 2 ); $iCount = count( $aProductsToAdd ); for( $i = 0; $i < $iCount; $i++ ){ $aReturn = dbCheckOrderProduct( $iOrder, aProductsToAdd[$i][0] ); if( !isset( $aReturn ) ) addOrderProduct( $aProductsToAdd[$i][0], $aProductsToAdd[$i][1], $iOrder ); } // end for header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' ); exit; } elseif( isset( $_POST['saveBasket'] ) ){ if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){ saveOrderProducts( $_POST ); } if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) ) setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 ); setCookie( 'sOrderQC_'.LANGUAGE, md5( $iOrder ), time( ) + 86400 ); if( !isset( $_COOKIE['sLanguage'] ) ){ setCookie( 'sLanguage', LANGUAGE, time( ) + 86400 ); } } elseif( $sOption == 'save' ){ if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){ saveOrderProducts( $_POST ); } if( isset( $_POST['sSave'] ) ){ header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' ); exit; } } } else{ if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) ) $iOrder = $_SESSION['iOrderSession_'.LANGUAGE]; } if( isset( $iOrder ) && is_numeric( $iOrder ) ) $sBasketList = listBasket( $iOrder, 'orders_basket.tpl' ); if( !empty( $sBasketList ) ) $content .= $sBasketList; else $content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' ); } elseif( $a == 'Delivery' ){ if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) ) $iOrder = $_SESSION['iOrderSession_'.LANGUAGE]; if( isset( $iOrder ) && is_numeric( $iOrder ) ){ if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){ if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){ saveOrder( $iOrder, $_POST ); $aData = throwOrder( $iOrder ); $sBasketList = listBasket( $iOrder, 'orders_summary.tpl' ); if( !empty( $sBasketList ) ){ $aData['fSummary'] = tPrice( $aData['fCourierPrice'] + $aList['fSummary'] ); $aData['sSummary'] = changePriceFormat( $aData['fSummary'] ); $sBasketList .= $tpl->tbHtml( 'orders_summary.tpl', 'COURIER' ); } $content .= $tpl->tbHtml( 'orders_summary.tpl', 'SHOW' ); unset( $_SESSION['iOrderSession_'.LANGUAGE] ); } else $content .= $tpl->tbHtml( 'messages.tpl', 'FORM_ERROR' ); } else{ $sBasketList = listBasket( $iOrder, 'orders_delivery.tpl' ); if( !empty( $sBasketList ) ){ $sCouriersSelect = listCouriers( 'couriers_select.tpl' ); $sBasketList .= $tpl->tbHtml( 'orders_delivery.tpl', 'COURIER' ); $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'FORM' ); } else $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'NOT_FOUND' ); } } else $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'NOT_FOUND' ); } ?> Thanks, Rodney
2007-08-02 10:17
You have: $aReturn = dbCheckOrderProduct( $iOrder, aProductsToAdd[$i][0] ); and it should be: $aReturn = dbCheckOrderProduct( $iOrder, $aProductsToAdd[$i][0] );
rodney 2007-08-02 14:24
That worked, but not the way I needed it to. It only adds the products if you hit the My Cart button and not when a product is added. If you add a regular product to the basket and check out, the automatic products are never added.
2007-08-02 20:32
Like to see what you have, in action.....
rodney 2007-08-02 21:40
Check it out here: http://ramcomputers.no-ip.org:82/qcart/index.php?p=ordersBasket Rodney
2007-08-02 21:55
Im on a Mac 10.4.9 using Safar 2.0.4 - Firefox 2.2 and Mozilla 5.0 --All browsers have the same thing happen -- after you add an item to the cart and the orders basket page displays, you are unable to delete any item from the list. Also looked around for the adding to the cart stuff - where is it?
rodney 2007-08-02 23:38
Thats not what I mean, If you hit the my cart link you will notice that two items are automatically add to the cart. I want the items to be added when you add a product to the basket. Lets say you order some Lollipops and you hit the Add to Basket Button, thats when I want the automatic products added. Not when you hit the my cart button on the top menu bar. Rodney
2007-08-03 02:31
OK I get it - it adds after, not before...
rodney 2007-08-03 17:31
Is there any way to solve this problem? Rodney