Skip to content

Instantly share code, notes, and snippets.

View MrImranJaved's full-sized avatar
🙂
Open For Opportunity

Imran Javed MrImranJaved

🙂
Open For Opportunity
View GitHub Profile
@adrianhajdin
adrianhajdin / StateContext.js
Last active July 11, 2024 14:11
Build and Deploy a Modern Full Stack ECommerce Application with Stripe
import React, { createContext, useContext, useState, useEffect } from 'react';
import { toast } from 'react-hot-toast';
const Context = createContext();
export const StateContext = ({ children }) => {
const getLocalStorage = (name) => {
if (typeof window !== 'undefined') {
const storage = localStorage.getItem(name);
@Rahmon
Rahmon / get_post_categories.php
Last active June 21, 2023 11:43
Get the post categories preserving the hierarchical order (WordPress)
<?php
/**
* Get the post categories preserving the hierarchical order
*
* This function returns an array with the following structure
*
* [
* [parent_term_id] => [
* [children] => [
* [child_term_id] => [
@peterfabian
peterfabian / rest_api_errors.txt
Created July 2, 2020 13:40
WP errors from the WooCommerce REST API directory
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/&lt;product_id&gt;/variations/&lt;id&gt; endpoint.', 'woocommerce' ), array( 'status' => 404 ) );
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocom
@smartrashed
smartrashed / Simple Ajax Login Form.php
Created November 7, 2019 07:49 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@Garconis
Garconis / .htaccess
Created August 24, 2019 05:33
Cloudways | .htaccess rewrite URL to HTTPS with WWW
# Cloudways force HTTPS with WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
<?php
$catTerms = get_terms('product_cat', array(
'hide_empty' => 0,
'orderby' => 'ASC',
'child_of'=>'30' // air sampling applications
));
echo '<ul>';
foreach($catTerms as $catTerm) {
echo '<li>
<a href="'. get_term_link($catTerm) .'" >' . $catTerm->name.'</a>
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Jun 07, 2019 at 07:58 AM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
/*-------------------Default Styles------------------------*/
.oxy-woo-checkout {
width: 100%;
}
td.download-file a.button.alt {
width: 100%;
}
.woocommerce ul.order_details {
background: #f7f6f7;
padding: 20px;
Step 1: Add Data in a Custom Session, on ‘Add to Cart’ Button Click
<?php
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
{
//Custom data - Sent Via AJAX post method
$product_id = $_POST['id']; //This is product ID
$user_custom_data_values = $_POST['user_data']; //This is User custom value sent via AJAX
@gdarko
gdarko / file-upload.css
Last active March 11, 2023 21:11
WordPress Custom Profile Image Ajax Upload
.upload-thumb {
display: inline-block;
width: 120px;
height: 120px;
overflow: hidden;
background: #e2e2e2;
border: 1px solid #cdcdcd;
line-height: 120px;
margin-bottom: 10px;
}