Custom Out Of Stock Actions

Hi guys,



I want to change the default Out of Stock parameters, in order to apply the required ones.

My options are different from category to category (root only). And also, I use Product Options / Option Combinations to all the products inserted.



For example, if x Products are in Category 1 (which is root) and run out of stock, I want to appear Add to Cart button, even if I have track with options selected.

If y Products are in Category 2 (root) and run out of stock, I want to appear the Sign-up for notification button. and so on…



Which is the best way to do this? Work in My changes (add-on) or create Custom Add-on?



I have started to create a Custom One, and display the options with radiogroup. The interface is set up, but it needs to be hooked up and I am kind of stuck a bit.



Any ideas / suggestions you might want to share?

Thanks a lot,

ids_out_of_stock_addon.jpg

[quote name='robert_p' timestamp='1310670214' post='117317']

Hi guys,



I want to change the default Out of Stock parameters, in order to apply the required ones.

My options are different from category to category (root only). And also, I use Product Options / Option Combinations to all the products inserted.



For example, if x Products are in Category 1 (which is root) and run out of stock, I want to appear Add to Cart button, even if I have track with options selected.

If y Products are in Category 2 (root) and run out of stock, I want to appear the Sign-up for notification button. and so on…



Which is the best way to do this? Work in My changes (add-on) or create Custom Add-on?



I have started to create a Custom One, and display the options with radiogroup. The interface is set up, but it needs to be hooked up and I am kind of stuck a bit.



Any ideas / suggestions you might want to share?

Thanks a lot,

[/quote]





I have been thinking again and maybe another better way is just to create another Out of Stock Options selectbox in Add / Update Product / General Tab section.

Instead of None / Buy in advance / Sign-up, I want to add Don't display / Add to cart.

But I want to to this without modifing the core, if is possible, mybe to use my_changes or something.



Any suggestions?

Hello,



I am having a strange behaviour for a function that I want to modify in addons/my_changes/.



I need to mod the fn_update_product_amount() from core/fn.cart.php.

I have added it exactly the was it was(from core) in addons/my_changes/func.php with the name fn_my_changes_update_product_amount().

I have set up a hook for it, from init.php, called by fn_register_hooks(… 'update_product_amount' …);



The $product_id and $amount are switched.

Instead of $product_id it shows me the $amount. If I call the function with $amount first, then $product_id etc… it displays ok.



Instead of decrease the product for the order, it increases it. It acts somehow, in opposite way that it should.



Any idea what's going on? Am I missing something?

Hello guys,



Can someone tells me why the foreach is performed only for 1 option/exception ?

If I have more than 1 forbidden exception, it skippes somehow…



Any ideas?

Thanks



$exceptions = db_get_array("SELECT product_id, combination FROM ?:product_options_exceptions WHERE product_id = ?i ", $product_id);
$j = 0;

foreach ($exceptions as $key=>$val){
$combination = unserialize($val['combination']);
foreach($combination as $k=>$v)
{
$j++;
$_combination .= $k."_".$v.'_';
if ( $j % 2 == 0 ){//insert one by one
$_combination = substr($_combination,0,(strlen($_combination)-1));
$_data = array (
'product_id' => $product_id,
'combination_hash' => $cart_id,
'combination' => $_combination,
'amount' => $new_amount,
'temp' => 'N',
'position' => '0'
);
// insert the amount & combination back in inventory
db_query("INSERT INTO ?:product_options_inventory ?e ", $_data);
// delete the exception based on this combination
db_query("DELETE FROM ?:product_options_exceptions WHERE product_id = ?i AND combination = ?s ",$product_id, $val['combination']);
$_combination = NULL;
$j = 0;
}

}


}

I have solved it.

Hi everybody,



I am trying for a couple of days to find a way to change the default rules for Out Of Stock Actions (oosa).

By that I mean the following:



default::

if oosa is set to S (subscribe when product comes in stock) works only if tracking = O (track with options)

if oosa is set to B (buy in advance) works only if tracking = D (do not track)



custom::

but if I have some product combinations that I dont want to display, if stock == 0 for a specific combination?

and if I want to display the add to cart button if some option combinations are out of stock and other ones are still in stock?

and if I want to appear a Sign up for notification, if a combination is out of stock, but the rest of combinations are in stock, and the tracking is set to O ?



Those default rules applies only if all of the combinations are 0 or all are in stock. individual cases are not included…



example::

(a product in size XL is available in Red color, but is not available in Green anymore).

For this situation, if I have OOSA set to Sign up for notification, this is working only with Track without options, but I want to continue traking my options combinations (O) and siaply that checkbox for the combination where stock is 0, erase the out of stock message. You see the picture?



I tried to mod some default rules (some of them works, some of them are in conflict with another option combinations), but I am wondering if there is a better way to do this. the point is to have/do/write something custom that can change/adjust the default rules for oosa.



Any ideas? Similar situations?