Skip to content

Instantly share code, notes, and snippets.

View shakhawat4g's full-sized avatar

Shakhawat Hossain shakhawat4g

View GitHub Profile
@shakhawat4g
shakhawat4g / functions.php
Created November 5, 2022 12:34 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@shakhawat4g
shakhawat4g / attributes-as-options.php
Created February 25, 2022 14:18 — forked from dazecoop/attributes-as-options.php
WooCommerce product attributes as selectable options without variations
<?php
/**
* List available attributes on product page in a drop-down selection
*/
add_action('woocommerce_before_add_to_cart_button', 'list_attributes_on_product_page');
function list_attributes_on_product_page() {
global $product;
$attributes = $product->get_attributes();
@shakhawat4g
shakhawat4g / Page Speed Incrase
Last active September 2, 2021 10:08 — forked from Zodiac1978/.htaccess
Make your Website faster - a safe htaccess way
<script>
$(function() {
var $q = function(q, res){
if (document.querySelectorAll) {
res = document.querySelectorAll(q);
} else {
var d=document
, a=d.styleSheets[0] || d.createStyleSheet();
a.addRule(q,'f:b');
for(var l=d.all,b=0,c=[],f=l.length;b<f;b++)
@shakhawat4g
shakhawat4g / addtocart.phtml
Last active September 4, 2015 15:07 — forked from lrkwz/addtocart.phtml
Magento quantity dropdown
<?php if ( Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getEnableQtyIncrements() ){ ?>
<select class="input-text qty" name="qty" id="qty">
<?php $i = (Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinSaleQty()?Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinSaleQty():1); ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i+= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQtyIncrements() ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMaxSaleQty()) ?>
</select>