Skip to content

Instantly share code, notes, and snippets.

View dariodev's full-sized avatar

Dario Devcic dariodev

  • Zagreb
View GitHub Profile
@dariodev
dariodev / acf-pagination.php
Created September 7, 2017 21:41 — forked from kisabelle/acf-pagination.php
ACF Repeater Field Pagination
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@dariodev
dariodev / gist:31717158d365c078cc0017a8e9b996e4
Created July 3, 2018 21:51 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551
@dariodev
dariodev / wc-change-price-display-custom-field.php
Created October 23, 2020 13:26 — forked from bekarice/wc-change-price-display-custom-field.php
Change WooCommerce price display with a custom field
<?php
// only copy the opening php tag if needed
// Change the shop / product prices if a unit_price is set
function sv_change_product_html( $price_html, $product ) {
$unit_price = get_post_meta( $product->id, 'unit_price', true );
if ( ! empty( $unit_price ) ) {
$price_html = '<span class="amount">' . wc_price( $unit_price ) . ' per kg</span>';
}
@dariodev
dariodev / functions.php
Created November 23, 2020 22:20 — forked from dangoodman/functions.php
WooCommerce: round up shipping prices
<?php
// Paste everything below this line to your child-theme's functions.php file.
// Rounds up all shipping rates by the $roundUpBy value.
// After pasting this snippet, reset the WooCommerce shipping cache, e.g. add an item to the cart.
add_filter('woocommerce_package_rates', function ($rates, $package) {
$roundUpBy = 5;
foreach ($rates as $rate) {
$rate->cost = ceil($rate->cost / $roundUpBy) * $roundUpBy;
}