0

How can I place a div between in stock and sku using xml for custom block.

I can only seem to place it after sku.

<body>
        <referenceBlock name="product.info.stock.sku">
            <block class="Stock\Qty\Block\LeftQty" name="catalog.product.view.stock"
                   before="product.info.stock.sku" template="Dolphin_MyModule::leftqty.phtml" cacheable="false"/>
        </referenceBlock>
    </body>

Product View Page

2 Answers 2

1

You can try this with css

Inside the product-info-stock-sku div, which is the parent div of the stock and sku you need to place your custom div inside this parent div

After that, add custom css

.stock available {
    -webkit-order: 1;
}
.product attribute sku {
    -webkit-order: 3;
}
.your_custom_div_class {
    -webkit-order: 2;
}
.product-info-main .product-info-stock-sku {
    display: grid;
}

enter image description here

enter image description here

Hope this will work for you :)

2
  • This works for in between IN STOCK and SKU. If I wanted to place it to the left or right of IN STOCK how would I achieve this.
    – Shaun
    Commented Dec 20, 2023 at 13:06
  • If it works then please give up-vote. The answer I gave was for your original question, to show custom text in between In Sotck and SKU. but you want to show left or right the In Stock then you need to override the main class for the sku and stock parent div which is .product-info-main .product-info-stock-sku you have to write your own css for that Commented Dec 20, 2023 at 13:16
0

you first go to your theme directory app/design/frontend/Mytheme/Default/Magento_Catalog/layout/ and create new file catalog_product_view.xml

<body>
    <move element="catalog.product.view.stock" destination="product.info.stock.sku" before="product.info.sku"/>
</body>

here => catalog.product.view.stock => your XML add name

I am also adding a custom block you want too. so please check the screenshot below for more information.enter image description here

For your more information "In stock" is get below file

vendor/magento/module-catalog/view/frontend/templates/product/view/type/default.phtml

and this file call in XML

/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view_type_simple.xml

if any issue then ask me again.

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.