Skip to content

Instantly share code, notes, and snippets.

<?php
add_action( 'woocommerce_add_order_item_meta', 'add_esn_fields');
public function add_esn_fields( $item_id, $values, $cart_item_key ) {
if($values['attached_id']){
$x = 1;
while($x <= $values['quantity']) {
wc_add_order_item_meta( $item_id, 'esn', '', false );
$x++;
}
}else if($values['type'] == 'wholesaler') {
add_action( 'woocommerce_add_order_item_meta', array( &$this, 'add_esn_fields'), 10, 3 );
public function add_esn_fields( $item_id, $values, $cart_item_key ) {
if($values['attached_id']){
$x = 1;
while($x <= $values['quantity']) {
wc_add_order_item_meta( $item_id, 'esn', '', false );
$x++;
}
}else if($values['type'] == 'wholesaler') {
$x = 1;
@asalkey
asalkey / woo-email.php
Created October 9, 2015 17:33
Programmatically trigger WooCommerce email
<?php
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) {
if ( $mail->id == 'wc_reminder_email' ) {
$mail->trigger();
}
}
@asalkey
asalkey / editable.php
Created October 9, 2015 17:20
Make any WooCommerce status editable
<?php
add_filter( 'wc_order_is_editable', 'processing_orders_editable', 10, 2 );
function processing_orders_editable( $is_editable, $order ) {
if ( $order->get_status() == 'processing' ) {
$is_editable = true;
}
return $is_editable;
}
@asalkey
asalkey / woo-override.php
Created October 9, 2015 17:15
Override WooCommerce templates in plugin
<?php
add_filter('wc_get_template','wholesaler_template'), 10, 5);
add_filter( 'wc_get_template_part', 'wholesaler_template_parts'), 10, 3);
public function wholesaler_template($located, $template_name, $args, $template_path, $default_path) {
global $woocommerce;
$newpath = plugin_dir_path( __FILE__ ) . '/woocommerce/' . $template_name;
return file_exists( $newpath ) ? $newpath : $located;
}
@asalkey
asalkey / designer.html
Created February 5, 2015 18:58
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../cool-clock/cool-clock.html">
<polymer-element name="my-element">
<template>
<style>
@asalkey
asalkey / auth.php
Last active October 20, 2015 02:42
Sentinel social basecamp controller
<?php
protected function oauth_url()
{
$callback = URL::to('oauth/callback');
$url = SentinelSocial::getAuthorizationUrl('basecamp', $callback);
return Redirect::to($url . '&type=web_server');
}
protected function oauth_callback()
@asalkey
asalkey / basecamp.php
Last active August 29, 2015 14:07
Basecamp provider
<?php use League\OAuth2\Client\Entity\User;
// Basecamp Oauth
class Basecamp extends League\OAuth2\Client\Provider\AbstractProvider {
// Response type
public $responseType = 'json';
@asalkey
asalkey / gist:d4b41f5726889aa41edd
Last active August 22, 2017 23:55
Woocoomerce: pull total with ajax
// Add an extra key + value
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<div class="total"> <?php echo $woocommerce->cart->get_cart_total(); ?> </div>
<?php
$fragments['total'] = ob_get_clean();
return $fragments;
Soundboard - Android App!https://play.google.com/store/apps/details?id=asalkey.soundboard&hl=en
Space Cat - HTML5 game!http://asalkey.github.io/spacecat/