M
M
Minusator2019-11-24 15:02:17
opencart
Minusator, 2019-11-24 15:02:17

How to do correct string replacement in ocmod opencart 2?

Good day!
With the help of ocmd I make a replacement in the price line, so that it turns out prices / unit of measure, but when the page is updated, the replaced line disappears, since the price update script is triggered depending on the quantity. Tell me how to fix the script so that the line is displayed correctly

<?php echo $product['price'] . ($product['unit'] ? '/' . $product['unit'] :''); ?>

ocmod
<operation error="skip">
            <search trim="true" index="0"><![CDATA[<?php echo $product['price']; ?>]]></search>
            <add position="replace" trim="false" offset="0"><![CDATA[<?php echo $product['price'] . ($product['unit'] ? '/' . $product['unit'] :''); ?>]]></add>
        </operation>

Script
var price_no_format = parseFloat(price);
  var new_price = (price_no_format + options_price) * quantity;
    var start_price = parseFloat($(mod +' .price_no_format_' + product_id).html().replace(/\s*/g,''));
    var price = new_price;
    $({val:start_price}).animate({val:price}, {
      duration: 400,
      step: function(val) {
        $(mod +' .price_no_format_'+product_id).html(price_format(val));
      }
    });

PHP
<span class="price_no_format_<?php echo $product['product_id'];?>"><?php echo $product['price']'); ?></span>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question