mmwfrank Developer Από United States Μέλος από Ιουλ 2023 mmwfrank 21 Οκτ 2023 08:50 I did a remix of zara's public domain '[url=https://www.litecart.net/en/addons/594/hide-price-if-zero-0-mod-zero-0-stock-contact-button]display inquire button[/url]' updating the text file with files (box_product.inc.php & listing_product.inc.php), and it seems to work OK. I wanted to make it a vMod add-on, but I haven't been able to make that work yet. Can someone tell me what I'm doing wrong? I tried it two different ways, inserting after/before and replacing. Neither worked. code using after/before insertion: <operation method="after" type="multiline" onerror="warning"> <find><![CDATA[ <?php echo functions::form_draw_hidden_field('product_id', $product_id); ?> ]]></find> <insert><![CDATA[ <?php if ($final_price == 0) { ?> <a href="<?php echo document::href_ilink('customer_service', ['subject' => $product_id]); ?>"> <button class="btn btn-success" type="button">Send an enquiry</button> </a> <?php } if ($final_price == 0) { echo ''; }else{ ?> ]]></insert> </operation> <operation method="before" type="multiline" onerror="warning"> <find><![CDATA[ <div class="stock-notice"></div> ]]></find> <insert><![CDATA[ <?php } ?> ]]></insert> </operation> </file> </vmod>``` and a replace try: ```<file name="public_html/cart/includes/templates/default.catalog/views/box_product.inc.php"> <operation method="replace" type="multiline" onerror="warning"> <find><![CDATA[ <?php echo functions::form_draw_hidden_field('product_id', $product_id); ?> ]]></find> <insert><![CDATA[ <?php echo functions::form_draw_hidden_field('product_id', $product_id); ?> <?php if ($final_price == 0) { ?> <a href="<?php echo document::href_ilink('customer_service', ['subject' => $product_id]); ?>"> <button class="btn btn-success" type="button">Send an enquiry</button> </a> <?php } if ($final_price == 0) { echo ''; }else{ ?> ]]></insert> </operation> <operation method="replace" type="multiline" onerror="warning"> <find><![CDATA[ <div class="stock-notice"></div> ]]></find> <insert><![CDATA[ <?php } ?> <div class="stock-notice"></div> ]]></insert> </operation> </file> </vmod>``` I asked a colleague to look it over for me when time permits, but knowing what I'm doing wrong will help out with another project I'm working on now. Thanks
jackmaessen LiteCart Fan Από Netherlands Μέλος από Δεκ 2022 jackmaessen 23 Οκτ 2023 07:21 So if i understand correctly: hardcoded in the file it works. But making it a vMod it fails?
mmwfrank Developer Από United States Μέλος από Ιουλ 2023 mmwfrank 23 Οκτ 2023 10:32 Yes, that's correct. Well, the files worked for me and I haven't seen any remarks that it doesn't work. I thought that doing the vMod would be simple, but still being a rookie at LC, not simple for me. I'm almost ready to release an add-on ([url=https://sortsupervisor.com]sortsupervisor.com[/url]) that I was hoping to use some vMod technology, so would really appreciate getting a handle on what I'm doing wrong. Thank you Jack.
mmwfrank Developer Από United States Μέλος από Ιουλ 2023 mmwfrank 24 Οκτ 2023 05:09 At least one issue is the wrong file name. I should have used "FS_DIR_APP" instead of "public_html/cart", and since I had the absolute address of my installation I doubt that anyone else got it to work either, unless they noticed and changed the address to theirs. I'll work on it more in a few days and see if I can get it working.
jackmaessen LiteCart Fan Από Netherlands Μέλος από Δεκ 2022 jackmaessen 24 Οκτ 2023 09:20 This one works for me in the demo: <operation method="after" type="multiline" onerror="warning"> <find><![CDATA[ <?php echo functions::form_draw_hidden_field('product_id', $product_id); ?> ]]></find> <insert><![CDATA[ <?php if ($final_price == 0) { ?> <a href="<?php echo document::href_ilink('customer_service', ['subject' => $product_id]); ?>"> <button class="btn btn-success" type="button">Send an enquiry</button> </a> <?php } if ($final_price == 0) { echo ''; }else{ ?> ]]></insert> </operation> <operation method="before" type="multiline" onerror="warning"> <find><![CDATA[ <div class="stock-notice"></div> ]]></find> <insert><![CDATA[ <?php } ?> ]]></insert> </operation> </file>``` I think you encounter a path problem with this line: ```<file name="public_html/cart/includes/templates/default.catalog/views/box_product.inc.php">``` zero_price.xml
mmwfrank Developer Από United States Μέλος από Ιουλ 2023 mmwfrank 24 Οκτ 2023 12:23 Wow, do I love that vMod technology, just like loading a product image, and bang it's done. And so much better than messing with the core files, especially when upgrade time comes around. Why don't you post the update to the add-on. I think if @zara would consider changing the name to something a bit shorter and more understandable, it might get more traction. Thanks Jack, I appreciate you fixing my dysfunctional update.
mmwfrank Developer Από United States Μέλος από Ιουλ 2023 mmwfrank 25 Οκτ 2023 21:49 I posted a new update to [url=https://www.litecart.net/en/addons/594/hide-price-if-zero-0-mod-zero-0-stock-contact-button]zara's add-on[/url].