Skip to content

Instantly share code, notes, and snippets.

View Paulsky's full-sized avatar

Paul Wijnberg Paulsky

View GitHub Profile
@Paulsky
Paulsky / LoadingButton.vue
Created April 19, 2024 11:01
Old LoadingButton component used in Laravel Nova before removal: https://github.com/laravel/nova-issues/discussions/6025
<template>
<button ref="button" v-bind="{ ...$attrs }" v-on="$listeners">
<span :class="{ hidden: processing || loading }">
<slot />
</span>
<span v-if="processing || loading">
<loader width="32" />
</span>
</button>
@Paulsky
Paulsky / wc-notice-functions.php
Last active April 10, 2024 09:31
Remove Woocommerce 'Added to cart' notice when the product is removed from the cart.
add_action('woocommerce_remove_cart_item', 'remove_added_to_cart_message_for_product', 10, 2);
function remove_added_to_cart_message_for_product($cart_item_key, $cart)
{
$product_id = $cart->removed_cart_contents[$cart_item_key]['product_id'];
$product = wc_get_product($product_id);
if (!$product) {
return;
}
@Paulsky
Paulsky / variations.js
Last active March 25, 2024 16:54
Automatically selects the only available 'Avada Button' type variation for WooCommerce products on the Avada theme.
(function(window, document, $) {
'use strict';
function handleVariationChange() {
$('.variations_form .avada-select-wrapper').each(function() {
const $wrapper = $(this);
const $buttons = $wrapper.find('.avada-button-select:not([data-disabled="true"])');
const $checkedButtons = $buttons.filter('[data-checked="true"]');
if ($buttons.length === 1 && !$buttons.attr('data-prevent-auto-select')) {