Jump to content

Updating checkbox field based on values from repeater field


Tyssen
 Share

Recommended Posts

I'm using a repeater field for holding stock levels of different items and when all the rows' quantity columns equal 0, I want to set another stock checkbox field to off.

I'm doing this in the template that displays the product:

foreach($page->inventory as $stock) :

  $stock_total += $stock->qty;

  if($stock_total==0) :
    $page->of(false);
    $page->stock = false;
    $page->save();
  endif;

endforeach;

but it's setting $page->stock to off whenever the page is refreshed regardless of whether $stock_total = 0 or not. Why is that?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...