Attribute acknowledgement at checkout

Hi All,
   Upon checkout, if a specific item has a attribute, show a checkbox or acknowledgment of that items attribute.
Ex:  Refrigerated item (attribute),  upon checkout show a checkbox that they are responsible for item upon delivery...

I think it would be something like:
<?php if (isset(reference::product($product_id)->attributes['XXX-XXX'])) { ?>   
        <?php echo language::translate('SHOW SOMETHING HERE', 'SHOW SOMETHING HERE'); ?>

Thanks,   Grant

tim

That looks right, what does the following show?


exit;```

Attached are images of what I did...and what I would like....
The var_dump I placed at the bottom of box_checkout_cart.inc.php, the resulting error is shown in image #2. Wrong place for it? 

I would like to place the notice in the checkout summary box, making it required as to be selected to checkout. 

Hope I am making sense. Thanks you Tim.
Grant

tim

Try $item['product_id'] instead of $product_id
That has to be within the foreach loop of items.

Hey Tim,
I tried the following in checkout_summary   and checkout_cart...

<?php if (isset(reference::$item['product_id']->attributes['15-215'])) { ?> 
        <?php echo language::translate('15-215', 'SHOW_SOMETHING_HERE'); ?>
<?php } ?>

End of file:
<script>
    var_dump(reference::$item['product_id']->attributes);
exit; 
</script>

I am not getting any errors, but its not showing anything either.  So: 
Am I putting the " var dump" in the correct place?

Thanks again
Grant

tim

reference::$item['product_id']->attributes['15-215']
Should be
reference::product($item['product_id'])->attributes['15-215']

Hey Tim,
   Just won't show anything OR its a error...?

<?php if (isset(reference::product($item['product_id'])->attributes['15-215']) { ?>   <----missing parenthesis?    tried with and without...
        <?php echo language::translate('15-215', 'SHOW_SOMETHING_HERE'); ?>
<?php } ?>

<script>
  $('textarea[maxlength]').bind('input', function() {
    var remaining = $(this).attr('maxlength') - $(this).val().length;
    $(this).closest('.input-wrapper').find('.remaining').text(remaining);
  });
  var_dump(reference::product($item['product_id']->attributes['15-215']));   <---added closing parenthesis...?
exit; 
</script>

Have tried this summary and cart boxes. With the same result...
" An unexpected error occurred, try reloading the page. "

Error Log: "syntax error, unexpected token "{" in ....public_html/cafe/includes/templates/blue.catalog/views/box_checkout_summary.inc.php on line 41

Thanks, Grant

tim

You can't execute PHP code on the client side. PHP code must go within <?php ?>.


  $('textarea[maxlength]').bind('input', function() {
    var remaining = $(this).attr('maxlength') - $(this).val().length;
    $(this).closest('.input-wrapper').find('.remaining').text(remaining);
  });
<?php // See what I did here.
  var_dump(reference::product($item['product_id'])->attributes['15-215']);
exit; 
?>
</script>```

I was expecting you would try something like this:

```<?php
  foreach ($items as $item) {
    var_dump(  reference::product( $item['product_id'] )  ->attributes  );
    ...
  }
?>```

A use case:
```<?php

  $is_detected = false;

  foreach ($items as $item) {
    if (isset(reference::product($item['product_id'])->attributes['15-215'])) {
      $is_detected = true;
      break;
    }
  }

  if ($is_detected) {
    echo 'Found';
  }
?>```

Thank you Tim, 
This worked in box_checkout_cart , couldn't get it to work in box_checkout_summary page.
place in location where you want to show:
<?php

  $is_detected = false;

  foreach ($items as $item) {
    if (isset(reference::product($item['product_id'])->attributes['15-215'])) {
      $is_detected = true;
      break;
    }
  }
  if ($is_detected) {   
echo language::translate('Refrigerated / Perishable', 'Refrigerated / Perishable');
  }
?>

Bottom of page:
<script>
<?php
  var_dump(reference::product($item['product_id'])->attributes['15-215']);
exit;
?>
</script>

Thanks you again Tim
Grant

Yes, that fixed that. Thanks Tim. I wish I understood all of it. It is GREATLY appreciated. 
Grant

This thread has been closed due to long inactivity. Posting to it is not possible.
View code on GitHub