Skip to content

Instantly share code, notes, and snippets.

View akshuvo's full-sized avatar

Akhtarujjaman Shuvo akshuvo

View GitHub Profile
@akshuvo
akshuvo / function.php
Last active May 28, 2022 14:37
Add WooCommerce product programmatically
<?php
// Product Title
$post_title = 'Test Product';
// Add Product
$new_post = array(
'post_title' => $post_title,
'post_type' => 'product',
'post_status' = > 'draft',
'post_content' => 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
@akshuvo
akshuvo / functions.php
Created October 5, 2020 23:12 — forked from riotxoa/functions.php
WooCommerce Coupons Fix: email restrictions
/*
WooCommerce email restriction for coupons does not work. This fix corrects it.
Include this code snippet in your theme or plugin.
*/
add_filter( 'woocommerce_coupon_is_valid', 'wc_riotxoa_coupon_is_valid', 10, 2 );
if ( ! function_exists( 'wc_riotxoa_coupon_is_valid' ) ) {
function wc_riotxoa_coupon_is_valid( $result, $coupon ) {
@akshuvo
akshuvo / WooCommerceOrderMethods.php
Created September 26, 2020 09:08
WooCommerce order all variables
<?php
global $woocommerce;
$order = wc_get_order( $order_id );
if ( $order ) {
$order->get_id();
$order->get_order_key();
$order->get_formatted_order_total();
$order->get_cart_tax();
<?php
/*
This script will allow you to send a custom email from anywhere within wordpress
but using the woocommerce template so that your emails look the same.
Created by craig@123marbella.com on 27th of July 2017
Put the script below into a function or anywhere you want to send a custom email
*/
<?php
function get_user_geo_country(){
$geo = new WC_Geolocation(); // Get WC_Geolocation instance object
$user_ip = $geo->get_ip_address(); // Get user IP
$user_geo = $geo->geolocate_ip( $user_ip ); // Get geolocated user data.
$country = $user_geo['country']; // Get the country code
return WC()->countries->countries[ $country ]; // return the country name
}
/* Add custom menu item and endpoint to WooCommerce My-Account page */
function my_custom_endpoints() {
add_rewrite_endpoint( 'refunds-returns', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
// so you can use is_wc_endpoint_url( 'refunds-returns' )
add_filter( 'woocommerce_get_query_vars', 'my_custom_woocommerce_query_vars', 0 );
@akshuvo
akshuvo / gist:3e7ef64919e80b2029e6ce4a6e05251e
Created April 16, 2020 17:47 — forked from ivandoric/gist:e4e46294c4d35eac0ec8
wordpress: create custom reset password page
<?php //Add all of this tu custom page template ?>
<?php
global $wpdb;
$error = '';
$success = '';
// check if we're in reset form
if( isset( $_POST['action'] ) && 'reset' == $_POST['action'] )
{
@akshuvo
akshuvo / geo-search-wp-query.php
Created April 11, 2020 16:31
Sort by distance WordPress post meta/ WordPress Query / pre_get_posts
<?php if(!defined('ABSPATH')) { die(); } // Include in all php files, to prevent direct execution
/**
* Plugin Name: WP Geo Query
* Plugin URI: https://gschoppe.com/wordpress/geo-searches/
* Description: Adds location search support to WP_Query, making it easy to create completely custom "Find Location" pages.
* Author: Greg Schoppe
* Author URI: https://gschoppe.com
* Version: 1.0.0
**/
npm install gulp --save-dev
npm install gulp-sass --save-dev
npm install gulp-autoprefixer --save-dev
npm install gulp-cssnano --save-dev
npm install gulp-header --save-dev
npm install gulp-jshint --save-dev
npm install gulp-rename --save-dev
npm install gulp-sourcemaps --save-dev
npm install gulp-uglify --save-dev
npm install gulp-util --save-dev
@akshuvo
akshuvo / gulpfile.js
Created March 10, 2020 11:20 — forked from leymannx/gulpfile.js
Gulp 4 Sass BrowserSync Kickstart Example
// Requires Gulp v4.
// $ npm uninstall --global gulp gulp-cli
// $ rm /usr/local/share/man/man1/gulp.1
// $ npm install --global gulp-cli
// $ npm install
const { src, dest, watch, series, parallel } = require('gulp');
const browsersync = require('browser-sync').create();
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');