0

I am building a custom theme

I need to change the configurable products "Add to Cart" button label to "See Options" in category page.

Only for the configurable product.

Any Help will Appreciate!!

2 Answers 2

0

If you want to change Add to Cart to See Options on product category (list page), You need to edit following file:

app/design/frontend/{Package}/{theme}/Magento_Catalog/templates/product/list.phtml

on list.phtml, You can check product type i.e

$_product->getTypeId();//it will give product type simple,configurable 

Based on product type you can change Add to cart text like:

<?php if($_product->getTypeId()=='configurable')  { ?>
<a class="product-button"
   href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>">
    <?= $block->escapeHtml(__('See Options')) ?>
</a>
<?php } else { ?>
    <button type="submit"
            title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
            class="action tocart primary">
        <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span>
    </button>
<?php } ?> 

Above code will change text only for configurable product and add a link to product view page.

Note: You need to remove original Add to cart button and add code given in solution.

2
  • Your solution works and you are the best, Thank you.
    – GeorgeM
    Nov 2, 2019 at 18:10
  • Welcome, Glad to know :)
    – Pawan
    Nov 5, 2019 at 2:34
0

I assume you find the list file from which the list of product code is there. So, just need to check in add to cart button with this code.

if($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)    
{    
     echo "product is configurable";
}

You just need to put add to cart label code in between the if condition and your work will be done.

Thanks

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.