Skip to content

Instantly share code, notes, and snippets.

View Niq1982's full-sized avatar

Niku Hietanen Niq1982

View GitHub Profile
@Niq1982
Niq1982 / show_stock.php
Created May 21, 2021 08:28
Woocommerce: Show stock amounts for a product depending on the local and wholesale stock
<?php
/**
* Echo stock amounts for a product depending on the local and wholesale stock
* quantities and possibly add wholesale information.
*
* @param int $product_id Product ID (optional)
*/
function show_stock( $product_id = 0 ) {
$product_id = $product_id ? $product_id : get_the_ID();
@Niq1982
Niq1982 / katselmus.md
Last active May 21, 2021 09:06
WP/Woocommerce Koodikatselmus part 1

WP/Woocommerce Koodikatselmus part 1

Katselmus on tehty WP/Woofi -facebookryhmässä silmiin osuneesta koodista alkup. tekijän luvalla.

Lähtökohtainen tilanne/tarve:

Tulee kokoajan tilauksia, joita perutaan paljon koska ei pystytä pitämään kiinni toimitusajoista. yli 9000 tuotetta ei pystytä oikein manuaalisesti päivittämään käsin joten tein pienenpienen (36 riviä) function joka selkeyttää Woocommercen stock statusta huomattavasti.

Jos saldo on:

  • &lt; 0 = Tilaustuote alla lukee Nkpl jälkitoimituksessa
@Niq1982
Niq1982 / card.php
Last active April 9, 2024 17:00
Load more to WordPress blog archive using AlpineJS and Axios
<div class="card">
<?php if ($args['link']) : ?>
<a href="<?php echo esc_url($args['link']); ?>" class="global-link">
</a>
<?php endif; ?>
<div class="card-image">
<?php wp_get_attachment_image($args['image']); ?>
</div>
@Niq1982
Niq1982 / README.md
Created February 26, 2024 09:11
Installing xdebug on ARM MacOS and VSCode

Install Xdebug

# Make sure you are using arm64 executable
> file `which php`
/opt/homebrew/bin/php: Mach-O 64-bit executable arm64

# Install
> arch -arm64 pecl install xdebug