hi i am developing an addon. when customers buy an product it will give free similar main product amount.
i dont want use promotions coz. its not promotion its routine procedure also promotions doesnt calculate amount.
anyway i build admin side product tabs, db and select one free product
used pre_add_to_cart hook
code
foreach ($free_products as $fp) {if (fn_check_free_promotion($fp['product_id']) == 'Y') { if (!isset($cart['products'][$p_id])) { $cart['products'][$p_id]['product_id'] = $fp['product_id']; $cart['products'][$p_id]['product_code'] = fn_get_product_code($fp['product_id']); $cart['products'][$p_id]['product'] = fn_get_product_name($fp['product_id']); $cart['products'][$p_id]['main_pair'] = fn_get_cart_product_icon($fp['product_id']); $cart['products'][$p_id]['amount'] = $data['amount']; $cart['products'][$p_id]['stored_price'] = 'Y'; $cart['products'][$p_id]['price'] = 0; $cart['change_cart_products'] = true; } else { $_initial_amount = empty($cart['products'][$p_id]['original_amount']) ? $cart['products'][$p_id]['amount'] : $cart['products'][$p_id]['original_amount']; $cart['products'][$p_id]['amount'] = fn_check_amount_in_stock($fp['product_id'], (($update == false) ? 0 : $_initial_amount) + $data['amount'], $data['product_options'] = null, $p_id, (!empty($data['is_edp']) && $data['is_edp'] == 'Y' ? 'Y' : 'N'), 0, $cart, $update == true ? $p_id : 0); } } }
its work when adding product adding free producs. also second adding updating amount.
also delete with delete_cart_product hook
problem is:
when re calculate cart. free products getting site price.
also how can i disable if free product in cart disable adding ?
and how can i disable free product qty changer ?
how can i fix this ?
thank you bosses