Skip to content

Instantly share code, notes, and snippets.

@haipham
haipham / AppServiceProvider.php
Created July 1, 2021 11:40 — forked from greenspace10/AppServiceProvider.php
Laravel, Livewire, Alpine JS Toast Notifications
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Component::macro('notify', function ($message, $title = '', $type = 'success') {
$this->dispatchBrowserEvent('notify', ['message' => $message, 'title' => $title, 'type' => $type]);
});
@haipham
haipham / Subscription.php
Created June 21, 2021 18:19 — forked from Shelob9/Subscription.php
Laravel Spark with Laravel Nova
<?php
namespace App\Nova;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;
@haipham
haipham / add-free-download-file.php
Created May 1, 2021 13:27 — forked from damiencarbery/add-free-download-file.php
Add free downloads to the WooCommerce My Account/Downloads page (a question from Facebook Advanced WooCommerce group - https://www.facebook.com/groups/advanced.woocommerce/permalink/1928688317145578/
<?php
/*
Plugin Name: Free Downloads for WooCommerce
Plugin URI: http://www.damiencarbery.com
Description: Add free downloads to the My Account/Downloads page.
Author: Damien Carbery
Author URI: http://www.damiencarbery.com
Version: 0.1
*/
@haipham
haipham / dynamic_input_fields.html
Created March 1, 2021 10:45 — forked from awebartisan/dynamic_input_fields.html
Dynamic input fields with Alpine.js
<div x-data="{ bankAccounts: [{
id: '',
accountNumber: ''
}] }">
<template x-for="(bankAccount, index, bankAccounts) in bankAccounts" :key="index">
<div class="grid grid-cols-6 gap-6 mt-2">
<div class="col-span-3 md:col-span-3 sm:col-span-2">
<x-jet-label for="city">Bank</x-jet-label>
<select :name="`bank_info[${index}][bank_id]`" id="bank"
class="border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm mt-1 block w-full">
@haipham
haipham / 2021_02_17_103523_migrate_to_jetstream.php
Created February 23, 2021 08:01 — forked from freekmurze/2021_02_17_103523_migrate_to_jetstream.php
Migrate classic Spark tables to Jetstream + new Spark
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MigrateToJetstream extends Migration
{
public function up()
{
@haipham
haipham / downloads.php
Created February 11, 2021 10:02 — forked from matrixwd/downloads.php
Adding Custom Fields Version Number to WooCommerce Downloads page
<?php break;
case 'download-product_version' :
$dl_id = $download['product_id'];
$version = esc_html( get_post_meta( $dl_id, 'version', true ) ); ?>
<span class="version"><?php echo $version; ?></span>
<?php break;
}
@haipham
haipham / my-account.php
Created February 10, 2021 17:05 — forked from ryanbeymer/my-account.php
Adds Tabs to WooCommerce "My Account" page. Instructions: add my-account.php to your [theme-folder]/woocommerce/myaccount/ folder.
<?php
/**
* A tabbed woocommerce My Account page
*
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@haipham
haipham / redirect-user-back-to-product.php
Created February 7, 2021 09:46 — forked from EvanHerman/redirect-user-back-to-product.php
WooCommerce - After login, redirect the user back to the last viewed product
<?php
/*
* Add a hidden field to our WooCommerce login form - passing in the refering page URL
* Note: the input (hidden) field doesn't actually get created unless the user was directed
* to this page from a single product page
*/
function redirect_user_back_to_product() {
// check for a referer
$referer = wp_get_referer();
// if there was a referer..
@haipham
haipham / skip-to-check-out.php
Created February 7, 2021 06:21 — forked from micc83/skip-to-check-out.php
Skip cart and redirect to direct checkout on WooCommerce
<?php
/**
* Skip cart and redirect to direct checkout
*
* @package WooCommerce
* @version 1.0.0
* @author Alessandro Benoit
*/
// Skip the cart and redirect to check out url when clicking on Add to cart