Questions tagged [if]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

How to write function if variable ends with...?

I have this function: if ($ order-> getData ('customer_email') == '[email protected]') I do not want to put a specific email but emails ending in '@marketplace.amazon.it' How ...
user95530's user avatar
0 votes
2 answers
717 views

Check if product exists within a specific category Magento 2

I want to check whether a product exists within a specific category and if true show message. At the moment I am having to do this via strpos using the Name attribute value. <?php if (strpos($...
YorkieMagento's user avatar
0 votes
1 answer
226 views

Can any conditional operators be used with an element while defining a multidimensional array?

While building a multi-dimensional array as shown below, I need to use a loop to retrieve some value from $this_fulfillment_record to be assigned to "amount" =>. Can a if statement be ...
CodeForGood's user avatar
1 vote
1 answer
16 views

Code optimization, adaptation to a large number of conditions

I need to make a condition, if the server code has a certain value, then it will set the appropriate currency. I did this via an if else condition. But if there are many 5+ conditions, it will look ...
Alice's user avatar
  • 148
1 vote
0 answers
25 views

Remove Price Based On Yes/No Attribute

I have created an attribute 'priceless' and I have successfully removed the add to cart button based on whether it is set to 'yes' or 'no'. I wish to do the same for the price field. If attribute '...
YorkieMagento's user avatar
0 votes
1 answer
348 views

Magento 1.9 - How to add if-else condition on Sales order email template HTML file?

Following is my sales order email template sample, Docroot = app\locale\en_US\template\email\sales\order_new.html <table cellpadding="0" cellspacing="0" border="0"> <tr>...
zus's user avatar
  • 145
0 votes
1 answer
82 views

Magento 1.9 - Custom message display at PDP page

I need to display delivery information on PDP page (app\design\frontend\default\theme\template\catalog\product) If SKU 66 the product delivery information is 5 To 15 Business Days For other product ...
zus's user avatar
  • 145
1 vote
1 answer
87 views

PHP if statement not working - AB testing

I've been working on a new modal design to be AB tested against the old version. However, I don't want to dive into third party AB testing code/frameworks so I have opted for a simpler approach. ...
Howliee's user avatar
  • 143
0 votes
1 answer
2k views

Magento 2 - Get current page type

I have a title.phtml which loads the page title for the pages in the webshop. What I need to do is detect whether it's a product page or something else... What is the best way yo do this? Regards,
n00bly's user avatar
  • 623
0 votes
1 answer
74 views

create block inside transactional emails to solve {{if}} problem

I'm new to magento. The problem that I have is that I want to modify the template of a transactional email. It's basically a return that I want the customer to receive a different email if the ...
dragon25's user avatar
2 votes
1 answer
234 views

Load css on condition

I need to a CSS file based on customer attribute when the user is logged. How can I do this ? Readed this : https://mage2.pro/t/topic/140 but it's based on backend config.
Morgan Tartreau's user avatar
2 votes
2 answers
471 views

Show link only if category has products Magento 1.9

I have code which outputs category images, names and links so that I can use a static block to output all categories within a parent. Currently each image/title is linked even if the category being ...
YorkieMagento's user avatar
0 votes
1 answer
263 views

Magento : Check if two conditions are true (category view)

I am trying to check if two conditions are true in the Magento category view file. Specifically if parent id = 1 and if category name = Nike. Can someone please suggest how I can update the code ...
YorkieMagento's user avatar
0 votes
3 answers
392 views

How to get Two Arrays of Categories in if/elseif Statement

I need to show different content on the product pages (view.phtml) Here is the code I have. The first array with the if statement works, it's getting the else if to work that I am having trouble with ...
Annie's user avatar
  • 11
0 votes
2 answers
4k views

Check if product has custom options Magento 2

I want to display some text next to the price of a product if it has custom options. I have placed some code in final_price.phtml but it doesn't show the message on custom option products. Can anyone ...
YorkieMagento's user avatar
0 votes
0 answers
380 views

Magento 2 display block in product page only when product belongs to specific category

I have a block showing up near the add-to-cart button, but I would like to display it only in some products from specific categories. Can i use something like this? {{conditions_encoded="a:2:[i:1;a:...
Sam Provides's user avatar
0 votes
2 answers
10k views

Help with if/else statement

<div class="stock"> <?php if($_product->isSaleable()): ?> <p class="prodstock"><?php echo $this->__('In stock') ?></p> <?php else: ?> &...
DevAnd's user avatar
  • 516
0 votes
2 answers
67 views

Show icon over images on specific category listing only

I'd like to show an icon only in my 'shoes' category listing page (ID: 3). I've put in place the PHTML which will create the icon in the list.phtml file. But currently it appears in all categories, I ...
YorkieMagento's user avatar
0 votes
1 answer
46 views

Why can't I call custom if-check on product view?

I've got a (custom) module which allows me to add YouTube video's to a product. I call that module in my local.xml like such: <block type="mymod_catalog/video" name="video" template="catalog/...
Asitis's user avatar
  • 1,237
1 vote
0 answers
53 views

Output Array with Matching IDs

I have 2 collection (customer and subinfo) that pull info from 2 separate database table. both table information are related and i needed to join/merge the info, which i have done. but unfortunately ...
Nxlevel's user avatar
  • 407
0 votes
1 answer
375 views

Adding icon to product listing image based on attribute value

I am trying to place a text icon on relevant product listing images based on an attribute value ('In Stock'). Can anyone tell me where I am going wrong, as I am crashing the page with the current code....
YorkieMagento's user avatar
0 votes
1 answer
114 views

Show value if customer logged in and customer email is X

I want to show a value on the product page that only an Admin can see. What is the best way to do this? I was thinking of an if statement that checks if I am logged in and also checks my email. It ...
Mike Tim Turner's user avatar
0 votes
1 answer
125 views

I need not to show this when one of the bundle products are out of stock

I have the following that shows a bundle of products on the product page: if ($_product->getAttributeText('bundle') == yes && $simplecount > 1): $product_ids = explode(',',$_product->...
Mike Tim Turner's user avatar
0 votes
1 answer
64 views

Fetch Category Image

I am attempting to display all sub-categories of a parent category on a static block page (e.g. brands will show all sub-categories such as Adidas, Nike etc.). I am having problems at the moment ...
YorkieMagento's user avatar
-2 votes
1 answer
386 views

how to add 2 attribute codes in if condition

i am using this code in attributes.phtml : <?php if ($_data['code'] == 'mobile_design') { ?> <td class="data"> <?php $_ageValues = $_product->getAttributeText($_data['code']); $...
Baby in Magento's user avatar
0 votes
1 answer
424 views

Hide price and add to basket for guests

I'd like to hide the price and add to cart button for guests not logged in to my Magento site. I'd also like to show a 'login or register to view prices' message for guests too. I imagine this will ...
YorkieMagento's user avatar
2 votes
6 answers
4k views

Call to a member function getName() on a non-object product view page

I have the following code on my product view page, calling the product's containing category title : <div class="page-title category-title"> <h1><?php echo $_category->...
YorkieMagento's user avatar
0 votes
3 answers
2k views

Show static banner or category banner on product page

I have the following code in product/view.phtml: <?php if(Mage::registry('current_category')): $_category=Mage::registry('current_category'); $_helper = Mage::helper('catalog/...
YorkieMagento's user avatar
2 votes
1 answer
352 views

Show static image on category if no category banner uploaded

I have the following code that displays my category banner image: <?php $_helper = $this->helper('catalog/output'); $_category = Mage::registry('...
YorkieMagento's user avatar
9 votes
1 answer
1k views

If Statements in CMS Page

This is what I am trying to do: {{if var data.request_quote=="on"}} Yes {{else}} No {{/if}} Where var data.request_quote is a form variable. It keeps coming out as No, even if data.request_quote is ...
Jimmery's user avatar
  • 1,499
1 vote
1 answer
138 views

Other way to build bootstrap framework with "else if"?

I have created a page for header.phtml I tried to change old design to new useful design with Bootstrap with my book. But I have a problem in two lines <?php else: ?> <?php endif;?>...
GYTO's user avatar
  • 121
0 votes
3 answers
142 views

Echo different text if specific product is in cart or not

I want to show "Text 1", when the Product with the ID 1 is in the cart. I want to show "Text 2", when the Product with the ID 1 is NOT in the cart. My code already works for "Text 1". This Text is ...
Aurya's user avatar
  • 1
0 votes
1 answer
50 views

Last class is not setting on last category in Array

We have an If statement which sets a class name to categories in the array, The first category has the class of "first" and the last category has the class of "last" however the Last class name is not ...
Adam Allen's user avatar
  • 2,205
0 votes
1 answer
1k views

want to echo a string in the price.phtml

I want to echo a string in my price.html and im using this if statement <?php if($_product->getData('bogof')==1){ echo 'test';} ?> but it doesn't print anything i know ...
Adam Allen's user avatar
  • 2,205
2 votes
1 answer
2k views

Want to display an Image if a customer group has a special price

I want to display an image in corner of our product images if a customer is logged into a specific group and that group has a special price. I have got the code for checking whether a customer is ...
Adam Allen's user avatar
  • 2,205
1 vote
1 answer
6k views

Checking if a product has an attribute set to yes

I have an attribute called BOGOF. Is there a way to display a pic on just to show the item is a buy one get one free item. The attribute is a yes/ no. Someone has given me this code in the past but ...
Adam Allen's user avatar
  • 2,205
0 votes
1 answer
244 views

how to disable free shipping if an attribute is true

I have created an if statement which I have on my shipping page. Where if the attribute "direct delivery" is true then it will display an error message and not show free delivery. I have put the If ...
Adam Allen's user avatar
  • 2,205
0 votes
1 answer
322 views

if statement display the error message more than once

i have a check in my checkout to see if a product has the attribute direct delivery set to yes and if so it should display a message. However if there is more than one product in the basket with the ...
Adam Allen's user avatar
  • 2,205
2 votes
1 answer
110 views

how to display a message if a product is direct delivery (attribute = yes)

I have an attribute called direct delivery. Is there a way to display a message on the shipping method page tell the customer they have a direct delivery item in their cart. The attribute "direct ...
Adam Allen's user avatar
  • 2,205
3 votes
1 answer
4k views

Need to display a warning message if a product from a certain category is in the cart

I need to add a warning message to my shipping methods page in the cart if a product from a certain category has been ordered. for example if our customer order furniture from the category ID 76 ...
Adam Allen's user avatar
  • 2,205
1 vote
1 answer
280 views

Getting products to appear if customer hasn't reached free delivery amount

I want to get a few products to display if a user hasnt reached our free delivery target (£75 excl VAT) so i tried to write in an IF statement in my cart.phtml file however i am not great at coding ...
Adam Allen's user avatar
  • 2,205
1 vote
1 answer
3k views

adding a sale image if the product is on sale

I have a table on my home page which shows 5 products from a category, I made called "Recommended For You". This works perfectly fine. The only thing I want to add is if the product has a special ...
Adam Allen's user avatar
  • 2,205
0 votes
1 answer
1k views

if statement for meta language tag on multi-language site

Going through some SEO lists and found that magento websites do not provide the proper meta language information in the head on all pages. Very simple to correct on uni-lingual websites, modify the ...
SR_Magento's user avatar
  • 5,209
0 votes
1 answer
2k views

if statement attribute condition & categories condition (2 conditions)

I have a large amount of products, about half do not have a proper description. To address this I've created an if statement that will display the product name one way and if the condition is not met ...
SR_Magento's user avatar
  • 5,209