0

I need to display a "Free Shipping" line of text below the price on the product page if the SKU starts with certain characters -- how do I got about doing this?

2 Answers 2

2

Assign the product sku to a vaiable and then you can check for the certain characters you are targetting.

if (strpos($_product->getSku(),'yourSKUpattern') !== false):
echo 'free shipping message';
endif;

Updated my answer just put in your pattern to check for and this should work

4
  • Could you be more specific on how to "assign a product sku to a variable"? Aug 14, 2015 at 14:16
  • Sorry I updated my answer to skip variable assignment, you can get product sku using $_product->getSku(), using that directly in the if to check product sku
    – Bobadevv
    Aug 14, 2015 at 14:18
  • Exactly what I needed. Working flawlessly. Thanks! Aug 15, 2015 at 18:50
  • Good to hear enjoy
    – Bobadevv
    Aug 15, 2015 at 23:02
3

Step 1:- Please create Attribute at admin panel Go to >>Catalog >> Manage Attributes and click on Add New Attribute and create attribute. Input text filed 'Attribute Code", "Catalog Input Type for Store Owner" Please select Yes/No option, and save attribute.

Step 2:- Go to >>Catalog >> Manage Attributes Set and drag & drop created attribute for General folder, After that select which product page you want to display "Free Shipping" Go to Manage Product and select product.

Step3:- Go to magento website root directory app\design\frontend\MyPackage\MyTheme\template\catalog\product\view.phtml

Edit and add this code where you want to display on front-end product page.

Add your attribute code and replace the code "getFreeShippingProduct"`

<?php if ($_product->getFreeShippingProduct()):?>
<div class="free-shipping-product">
<div class="std"><?php echo $this->__('Free Shipping') ?></div>
</div>
<?php endif;?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.