cyber83 Designer Από Romania Μέλος από Ιουν 2024 cyber83 18 Σεπ 2024 13:53 I'd like to echo the Attributes selection from admin to all product by copying a code to box_product.inc.php I know this is related to options and filters, however if I add attributes in admin to a product example: Group Value Color Red Size Large etc. I'd like tis to apear on the product page as follows: Color: Red Size: Large -- I also know that this can be done on the "technical Information" however now we are adding this info in the technical information manually also selecting them on the Attribute page for each product. If I have this code that echoes out the above, i dont have to add the same info twice. i just add the attributes as normal and also automatically appears on the on the product page - the Options and Filers side of remains untoched and works as it works now.
jackmaessen LiteCart Fan Από Netherlands Μέλος από Δεκ 2022 jackmaessen 18 Σεπ 2024 15:49 File: [b]includes/templates/default.catalog.views/box_product.inc.php[/b] At the very top of the file add: $product = new ent_product($_GET['product_id']); $_POST = $product->data; ?>``` Then, the place where you want to appear the attrib values: ```<!---------------------Start attr adding--------------------------------> <table> <?php if (!empty($_POST['attributes'])) foreach (array_keys($_POST['attributes']) as $key) { ?> <tr> <td><?php echo functions::escape_html($_POST['attributes'][$key]['group_name']); ?></td> <td><?php echo functions::escape_html($_POST['attributes'][$key]['value_name']); ?></td> </tr> <?php } ?> </table> <!----------------------End attr adding-------------------------------->``` Note: Creating a vmod from this is better then modifying the original file!
dodo Moderator Από Lithuania Μέλος από Μαρ 2016 dodo 18 Σεπ 2024 20:28 It's completely safe to edit box_product file as it's template file and not the core. Just don't forget to rename your template folder from default. It's also possible to use reference: <table class="table data-table table-striped table-hover"> <?php if (!empty($product_attributes)) foreach (array_keys($product_attributes) as $key) { ?> ....```
cyber83 Designer Από Romania Μέλος από Ιουν 2024 cyber83 13 Φεβ 2025 17:15 This bit made the quantity filed on my product page to echo the stock Quantity <?php $product = new ent_product($_GET['product_id']); $_POST = $product->data; ?> I changed it to: $product = new ent_product($_GET['product_id']); $GLOBALS['product_data'] = $product->data; Instead of overriding $POST, store product->data in a separate global variable, like $productdata, and reference it where needed. -- Then, modified my table logic to reference $GLOBALS['product_data'] instead of $POST: ..in this way Quantity remains by default 1 and the rest of the codes are echoing back too <table> <?php if (!empty($GLOBALS['product_data']['attributes'])) { foreach ($GLOBALS['product_data']['attributes'] as $key => $attribute) { if (isset($attribute['group_name']) && stripos($attribute['group_name'], 'Band') !== false) { continue; // Skip this row if group_name contains 'Band' } ?> <tr> <td>● <?php echo functions::escape_html($attribute['group_name']); ?></td> <td><?php echo functions::escape_html($attribute['value_name']); ?></td> </tr> <?php } } ?> </table> On my page I specifcally use this: <table class="table" style="width: 100%; margin-bottom: 10px; margin-top: 30px;"> <tbody> <tr style="border-bottom: 1px solid #CCCCCC;"> <td colspan="2" style="font-size: 16px;"> PRODUCT PROFILE </td> </tr> </tbody> </table> <div class="technical-data"> <table class="table table-striped table-hover"> <tr> <td>● Brand</td> <td> <?php if (!empty($manufacturer)) { ?> <a href="<?php echo functions::escape_html($manufacturer['link']); ?>"> <?php echo $manufacturer['name']; ?> </a> <?php } ?> </td> </tr> <tr> <td>● Collection</td> <td><?php $cfield = 1; echo !empty($custom_fields[$cfield - 1]['value']) ? $custom_fields[$cfield - 1]['value'] : ''; ?></td> </tr> <tr> <td>● Product Name</td> <td><?php echo $name; ?></td> </tr> <tr> <td>● Product ID</td> <td>XID<?php echo $product_id; ?></td> </tr> <tr> <td>● Product Code</td> <td><?php $cfield = 2; echo !empty($custom_fields[$cfield - 1]['value']) ? $custom_fields[$cfield - 1]['value'] : ''; ?></td> </tr> <tr> <td>● Updated On</td> <td><?php echo language::strftime('%e %b %Y %H:%M', strtotime($product->date_updated)); ?></td> </tr> <?php // Insert product attributes dynamically, skipping 'Band' if (!empty($GLOBALS['product_data']['attributes'])) { foreach ($GLOBALS['product_data']['attributes'] as $key => $attribute) { if (isset($attribute['group_name']) && stripos($attribute['group_name'], 'Band') !== false) { continue; // Skip if 'Band' is in group_name } ?> <tr> <td>● <?php echo functions::escape_html($attribute['group_name']); ?></td> <td><?php echo functions::escape_html($attribute['value_name']); ?></td> </tr> <?php } } ?> </table> <table class="table" style="width: 100%; margin-bottom: 10px; margin-top: 30px;"> <tbody> <tr style="border-bottom: 1px solid #CCCCCC;"> <td colspan="2" style="font-size: 16px;"> FABRIC SPECIFICATIONS </td> <td> </td> </tr> </tbody> </table> <table class="table table-striped table-hover"> <tr> <td>● Price Band</td> <td><a class="link btn-default btn-sm" style="margin-top: 20px;" href="<?php echo "https://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); ?>/faq/what-are-the-price-bands" title="What are Price Bands?" data-toggle="lightbox" data-seamless="true" data-require-window-width="1" data-max-width="980"> <i class='fa fa-question-circle'></i></a> <?php $cfield = 3; echo !empty($custom_fields[$cfield - 1]['value']) ? $custom_fields[$cfield - 1]['value'] : ''; ?> </td> </tr> <?php /* if (!empty($_POST['attributes'])) foreach (array_keys($_POST['attributes']) as $key) { ?> <tr> <td>● <?php echo functions::escape_html($_POST['attributes'][$key]['group_name']); ?></td> <td><?php echo functions::escape_html($_POST['attributes'][$key]['value_name']); ?></td> </tr> <?php } */?> <?php if (!empty($_POST['attributes'])) { foreach ($_POST['attributes'] as $key => $attribute) { if (isset($attribute['group_name']) && stripos($attribute['group_name'], 'Band') !== false) { continue; // Skip this row if group_name contains the word 'Band' } ?> <tr> <td>● <?php echo functions::escape_html($attribute['group_name']); ?></td> <td><?php echo functions::escape_html($attribute['value_name']); ?></td> </tr> <?php } } ?>
s22_tech Moderator Από United States Μέλος από Οκτ 2019 s22_tech 22 Φεβ 2025 17:54 Just don't forget to rename your template folder from default. So there's no misunderstanding, NEVER change the name of your default template directories — always create new one's in /includes/templates/ with a custom name and then select your custom templates in the admin. If you rename LC's folders, you could end up breaking your cart. I'm sure that's what dodo meant, but an ounce of prevention is worth a pound of cure. 😉
cyber83 Designer Από Romania Μέλος από Ιουν 2024 cyber83 22 Φεβ 2025 19:18 I use vmods for changing the template, and use the default template