简体   繁体   中英

magento check if product value contains a specific word

Working with magento I have a custom option for a product which has rows with a date and then a location as it's title. For example the options could be: *

  • 29th October - London,
  • 26th November - Leeds,
  • 28th November - London.

Is it possible to write an if else statement based on just part of the custom option's title value?

for example

<?php if($value == "Leeds"): ?>
Content
<?php else : ?>
other content 
<?php endif : ?>

Also, how to I call the custom option values?

Take a look at strpos and preg_match

$mystring = '6th November - Leeds';
$findme   = 'Leeds';
$pos = strpos($mystring, $findme);

if ($pos !== false) {
     // Content
} else {
     // other content
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM