Skip to content

Instantly share code, notes, and snippets.

View cosminsc's full-sized avatar

Cosmin S. cosminsc

View GitHub Profile
@cosminsc
cosminsc / skip-to-check-out.php
Last active May 8, 2019 07:44 — 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
<?php
/**
* Plugin Name: WooCommerce Settings Tab Demo
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a
* Description: A plugin demonstrating how to add a WooCommerce settings tab.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@cosminsc
cosminsc / update-woo-order-billing-when-user-saves-address.php
Created September 27, 2018 16:07 — forked from zgordon/update-woo-order-billing-when-user-saves-address.php
Update WooCommerce Order Address Dynamically When Customer Updates Their Address
<?php
add_action( 'woocommerce_customer_save_address', 'jsforwp_update_address_for_orders', 10, 2 );
function jsforwp_update_address_for_orders( $user_id ) {
$customer_meta = get_user_meta( $user_id );
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
@cosminsc
cosminsc / cart.php
Created September 26, 2018 18:12 — forked from alordiel/cart.php
[WooCommerce 3.2.6] Get product variations from cart items (used in cart.php)
<?php
//Loop through each item from the cart
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
//get the current product ID
$product_id = $cart_item['product_id'];
//first - check if product has variations
if(isset($cart_item['variation']) && count($cart_item['variation']) > 0 ){
//get the WooCommerce Product object by product ID
$current_product = new WC_Product_Variable($product_id);
//get the variations of this product
@cosminsc
cosminsc / functions.php
Created June 13, 2018 15:30 — forked from woogist/functions.php
Change the subscription thank you message after purchase
/**
* Change the subscription thank you message after purchase
*
* @param int $order_id
* @return string
*/
function custom_subscription_thank_you( $order_id ){
if( WC_Subscriptions_Order::order_contains_subscription( $order_id ) ) {
$thank_you_message = sprintf( __( '%sThank you for purchasign our subscription! Visit %syour account%s page to know its status.%s', 'woocommerce-subscriptions' ), '<p>', '<a href="' . get_permalink( wc_get_page_id( 'myaccount' ) ) . '">', '</a>','</p>' );
@cosminsc
cosminsc / build_google_font_url.php
Last active September 2, 2022 22:09
Build Google Font URL
<?php
/**
* Google Font URL
* Combine multiple google font in one URL
* @link https://shellcreeper.com/?p=1476
* @author David Chandra <david@shellcreeper.com>
*/
function tamatebako_google_fonts_url( $fonts, $subsets = array() ){
/* URL */
@cosminsc
cosminsc / google_font_importer.php
Created May 21, 2018 09:51 — forked from PeterBooker/google_font_importer.php
Imports Google Webfonts and creates a Dropdown to select a font from.
<?php
/*
* Google Font Importer
*/
$fonts = "https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyCpfnm5kVng8hhP_jnAnnTXVP7MEUM89-k";
$fonts = file_get_contents($fonts, 0, null, null);
$fp = fopen('fonts.txt', 'w');
@cosminsc
cosminsc / Component.jsx
Created May 16, 2018 08:11 — forked from krambertech/Component.jsx
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();