Hi Vdub,
Thanx for this modification... and J. Jezek thanx for the original code, it kept me thinking. After a little bit of puzzling I think the problem is solved. I modified the code and made a file from it (called: free.product_add.php). See here below the main part of this file which ables you to add a free product when a certain order-amount has been reached
OPTION 1.
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @version $Id: free.product_add.php $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2007-2008 Marlon. All rights reserved. Inspired by the code from J. Jezek and Modification by Vdub.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName( __FILE__ );
global $page;
if ( $total > 150.00) {
echo "<table width=\"100%\"><tr><td>
<form action=\"".$mm_action_url . "index.php\" method=\"post\" name=\"addtocart\" id=\"addtocart\">
<center><h2>Your order value is over € 150.00</h2></center>
<center><h3>Please add your free gift below</h3></center>
<!-- Replace Product-ID-number in the value field to the desired product-id -->
<input type=\"hidden\" name=\"product_id\" value=\"18\" /><img src=\"productimage.jpg\"><br />some text like: only one item is allowed<br />
<!-- Replace Category-ID-number in the value field to the desired category-id -->
<input type=\"hidden\" name=\"category_id\" value=\"7\">
<input type=\"hidden\" name=\"page\" value=\"shop.cart\">
<input type=\"hidden\" name=\"func\" value=\"cartadd\">
<input type=\"hidden\" name=\"option\" value=\"com_virtuemart\">
<input type=\"submit\" value=\"add FREE product\">
</form>
</td></tr></table>";
}
?>
Save this code above as:
free.product_add.php and put it in administrator\components\com_virtuemart\html
Then open basket.php (administrator\components\com_virtuemart\html) and add after:
/* Input Field for the Coupon Code */
if( PSHOP_COUPONS_ENABLE=='1'
&& !@$_SESSION['coupon_redeemed']
&& ($page == "shop.cart"
|| @$checkout_this_step == CHECK_OUT_GET_PAYMENT_METHOD
|| @$checkout_this_step == CHECK_OUT_GET_SHIPPING_ADDR && CHECKOUT_STYLE != 3
|| @$checkout_this_step == CHECK_OUT_GET_SHIPPING_METHOD && CHECKOUT_STYLE == 3
)
) {
include (PAGEPATH."coupon.coupon_field.php");
}
the following code:
/* begin of Field for the Free Product Code */
if($show_basket
&& ($page == "shop.cart"
)
) {
include (PAGEPATH."free.product_add.php");
}
/* end of Field for the Free Product Code */
Now when the total amount is € 150, the FREE product field will appear in the first Cart page. And this field will disappear going to the checkout. You can change the amount to your desired amount.
Good luck,
Marlon
NOTE please also follow the instructions that Vdub describes in his post above
You will need to set up a new catergory and make sure it is unpublished
Add your products to this category valued at 0.00
SEE ALSO UPDATED CODE BELOW!!!
-----