mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 17 พ.ค. 2022 23:12 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 Founder จาก Sweden เป็นสมาชิกตั้งแต่ พ.ค. 2013 tim 17 พ.ค. 2022 23:51 That looks right, what does the following show? exit;```
mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 18 พ.ค. 2022 01:39 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 Founder จาก Sweden เป็นสมาชิกตั้งแต่ พ.ค. 2013 tim 18 พ.ค. 2022 02:03 Try $item['product_id'] instead of $product_id That has to be within the foreach loop of items.
mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 18 พ.ค. 2022 03:00 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 Founder จาก Sweden เป็นสมาชิกตั้งแต่ พ.ค. 2013 tim 18 พ.ค. 2022 03:37 reference::$item['product_id']->attributes['15-215'] Should be reference::product($item['product_id'])->attributes['15-215']
mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 18 พ.ค. 2022 19:12 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 Founder จาก Sweden เป็นสมาชิกตั้งแต่ พ.ค. 2013 tim 18 พ.ค. 2022 21:32 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'; } ?>```
mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 18 พ.ค. 2022 23:09 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
tim Founder จาก Sweden เป็นสมาชิกตั้งแต่ พ.ค. 2013 tim 18 พ.ค. 2022 23:57 The items don't seem to have product_id defined for the checkout_summary view. https://github.com/litecart/litecart/blob/64e60406e32cfd7f6898ef803637bf6219b94631/public_html/pages/ajax/checkout_summary.inc.php#L80-L89 So add it: 'product_id' => $item['product_id'], I will add that for the next version.
mobgro LiteCart Fan จาก United States เป็นสมาชิกตั้งแต่ ธ.ค. 2016 mobgro 19 พ.ค. 2022 00:06 Yes, that fixed that. Thanks Tim. I wish I understood all of it. It is GREATLY appreciated. Grant