Skip to content

Instantly share code, notes, and snippets.

View suhag10's full-sized avatar
🎯
Focusing

Suhag Ahmed suhag10

🎯
Focusing
View GitHub Profile

Handle quantity increments and decrements

Modularized code into reusable functions.

jQuery(function ($) {
    /**
     * Utility: Get decimal places of a number string
     */
    if (!String.prototype.getDecimals) {

Get Product Stock

global $product;

echo wc_get_stock_html( $product );

// OR

$stock_quantity = $product->get_stock_quantity();

Get Product Category

global $product;

$product_id  = get_the_ID();
$product_cat = get_the_terms( $product_id, 'product_cat' );

echo esc_html(implode(', ', wp_list_pluck($product_cat, 'name')));
{
"name": "yourName/project-name",
"description": "project description.",
"type": "wordpress-plugin",
"license": "GPLv2",
"authors": [
{
"name": "Your Name",
"email": "your-email@domain.com"
}
<?xml version="1.0"?>
<ruleset name="Project Name">
<rule ref="WordPress">
<exclude name="WordPress.Files.FileName"/>
</rule>
<arg name="extensions" value="php"/>
<file>.</file>
<exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>