Community Forum

If you have questions about my software, chances are this forum has the answers.

You'll need to register before you can post on the forum to ask your question or to answer another one. A reply will be posted to each and every question that is asked so there is no need to double post or bump your post. I do my best to answer promptly but in some cases it may take a day or two. If you bump your post, it may be removed. Bear with me and I`ll get your question answered quickly.

Here are a few tips to help you to get your questions answered more rapidly.

IMPORTANT: Posts in English only. I don't have a translator and I'll be unable to understand your message properly and will probably delete it.
SEARCH: Use the search option to see if your question has been answered on the forum before now or if there is an answer in the documentation of your software.
PRIORITY SUPPORT: If you have purchased a commercial version of any software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
LINKS: Any links posted are not clickable and must be copied / pasted into your browser address bar.

You are not logged in.

#1 jjjjeczalik 24-01-2017 23:00:06

I am betraying my ignorance of PHP here; nevertheless...

While modifying Maianmusic over the past few months, I have often made certain things conditional upon other things, e.g.,

 if ($this->COLLECTION->catnumber<100) 

then do such-and-such (making certain products display sheet music or lyrics, etc.), or

 if (LOGGED_IN=='yes') 

then do so-and-so (making certain products display sheet music or lyrics, making certain products only visible when you're logged in, etc.).

Applying the same logic to

 if ($this->CHARGES['total']>0) 

fails every time. The value is always zero, even though the correct amount will always display if I

 echo $this->CHARGES['total'] 

What I am trying to do is this: IF the cart total is $0.00 then X but if the cart total is greater than $0.00 then Y. This isn't a MaianMusic bug, because the correct total still always displays in the basket, but rather, it's something obvious that I'm missing. (Every question that I post here ends up being something obvious that I'm missing. So I post here instead of in priority support because these are things that are not problems with the software, but questions that are being answered out of kindness.)

To clarify, everything that I'm doing in this instance is on the basket.tpl.php page.

#2 msworld 25-01-2017 07:03:14

The reason it`s failing is because the $this->CHARGES['total']  variable isn`t numeric or a float, it also contains the currency symbol.

So, you need to get only the price from the string before comparing. Something like this should work ok.

preg_match('/\d+(?:\.\d+)+/', $this->CHARGES['total'] , $matches);
if ($matches[0] > 0) {
  // greater..
} else {
#3 jjjjeczalik 27-01-2017 15:27:17
msworld wrote::

The reason it`s failing is because the $this->CHARGES['total']  variable isn`t numeric or a float, it also contains the currency symbol.

I had a feeling that that was it, as I had started fooling around with


but I travelled beyond my skill level. Thanks for your help!

#4 msworld 29-01-2017 14:11:29

You are welcome. smile

Board footer

Maian Script World - Free PHP Software for Personal or Business Use.
© 2003-2019 Maian Script World & David Ian Bennett. is an authorized reseller of goods and services provided by Maian Script World

Free PHP Software / Responsive PHP Scripts / Lightweight PHP Software / White Label PHP Software