1. peterva
  2. RO CSVI
  3. Sunday, 01 March 2015
  4.  Subscribe via email
Hi, I am trying to subtract a number from my product_in_stock value, to create a safety margin when exporting quantities.

Let's say my product_in_stock has a value of 30, I want the output to be 25.

I tried setting the default value for this field to -5. But the export result is still 30, so this doesn't work.

When I try a replacement with a regular expression:
input: /(.*)/e
replace with: ('\1')-5
the output is 25-5 (so the subtraction works but -5 gets added as text to the result).

I am not a champion of regular expressions. Anyone know how to get the result I want?
Thanks!
Accepted Answer Pending Moderation
Hello,

You are missing a PHP function in the replace for it to make it a number. You can try this but no guarantees :)
floatval('\1')-5
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Nope, still 30-5 :S
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Another try maybe
floatval(('\1')-5)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Nope, it gives the same result.

But I have applied a second replace string:

find: 0-5|1-5|2-5|3-5|4-5|5-5|6-5|7-5|8-5|9-5
replace: 0|1|2|3|4|5|6|7|8|9
regular text

Now I get the correct output.
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
Creativity rules :)
Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!