Skip to content

Instantly share code, notes, and snippets.

View msulaimanmisri's full-sized avatar
🎯
Focusing

Muhamad Sulaiman Misri msulaimanmisri

🎯
Focusing
View GitHub Profile
@msulaimanmisri
msulaimanmisri / custom-boot-migration.txt
Last active March 28, 2024 17:10
Custom method to make Laravel Migration read the sub-folders inside migration folder
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@msulaimanmisri
msulaimanmisri / index.php
Created July 13, 2023 02:19
This will enable HPOS at BillPlz WooCommerce Plugin
<?php
/**
* Use this code only at Development @ Local Environment. DO NOT USE AT PRODUCTION SITE
* First, go to BillPlz for WooCommerce WordPress Plugin and then open file named `billPlzWoo.php`
*Then, copy and please this code. Only put the code line 19 and method named `enableHposForBillPlz`
*/
protected function __construct()
@msulaimanmisri
msulaimanmisri / woocommerce-shipping-based-on-cart
Created April 3, 2023 15:58
This will turn Shipping fee based on Cart total
/**
* @author SulaimanMisri
* Load the logic
*/
function makeShippingChangeBasedOnCartTotal( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
$total = WC()->cart->subtotal;
@msulaimanmisri
msulaimanmisri / Laravel Accessors & Mutators
Created October 22, 2022 18:03
This syntax will make your development faster without need to type each time you want to render PHP syntax such as ucwords() or preg_replace()
/**
* @author Muhamad Sulaiman Misri
*/
trait TransformOrderTitle {
protected function orderTitle(): Attribute {
return Attribute::make(
/**
* This will show your string as Uppercase.
@msulaimanmisri
msulaimanmisri / show old value in Laravel Blade <select>
Last active October 22, 2022 18:06
When Laravel validation appear, Laravel Old Helper will not selected by default. We can use JavaScript to make it happen.
/**
* @author Muhamad Sulaiman Misri
*/
const oldValueOfYourSelector = '{{ old('selector') }}';
if (oldValueOfYourSelector !== '') {
$('selector').val(oldValueOfYourSelector);
}
@msulaimanmisri
msulaimanmisri / jQuery show and hide based on <select>
Created October 22, 2022 06:53
jQuery show and hide based on <select>
/**
* @author Muhamad Sulaiman
*/
$("selector").hide();
$(function() {
$("selector").change(function() {
@msulaimanmisri
msulaimanmisri / sm_wc_random_product.php
Created July 4, 2022 07:41
WordPress WooCommerce Random Product
<?php
/**
* @author Muhamad Sulaiman
* @link https://github.com/msulaimanmisri
*/
function sm_wc_random_products( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters('woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'random_list' == $orderby_value ) {