Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: Woocommerce SMS Notification
Plugin URI: http://kohbeixian.com
Description: Woocommerce SMS Notification (BulkSMS and WooCommerce Marketplace)
Version: 1.0
Author: Xian
Author URI: http://kohbeixian.com
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Make sure WooCommerce is active
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return;
add_action('woocommerce_order_status_completed', 'custom_process_order', 10, 1);
function custom_process_order($order_id) {
return $order_id;
}
$order = new WC_Order( $order_id );
$order_meta = get_post_meta($order_id);
$vendors = array();
$items = $order->get_items();
foreach ($items as $item) {
$prodid = $item['product_id'];
$vends = get_the_terms($prodid, 'dc_vendor_shop');
foreach ($vends as $vend) {
if (!in_array($vend, $vendors)) {
array_push($vendors, $vend);
$sellermessage = "From: Bei Xian Koh\r\nNew order notification: Order #".$order_id."\r\nBuyer First Name: ".$buyer_firstname."\r\nBuyer Last Name: "
.$buyer_lastname."\r\nBuyer Email: ".$buyer_email."\r\nBuyer Phone: ".$buyer_phone."\r\nTotal Price: ".$ordertotal;
$sellermessage = rawurlencode($sellermessage);
$vphone = '';
foreach ($vids as $v) {
// send sms to vendors
$vphone = get_user_meta($v, 'billing_phone', true);
}
//get wcmp vendor details
$buyermessage = "From: Bei Xian Koh\r\nSummary of your order: Order #".$order_id."\r\nTotal Price: ".$ordertotal;
<p>
<a href="https://outlook.live.com/owa/?path=/calendar/view/Month&rru=addevent&dtstart=2018-02-07t20:00:00+00:00&dtend=2018-02-07t22:00:00+00:00&subject=Spanish+Cooking+Class&location=Cooking+Hall">Click here to add event to your Outlook Calendar</a>
</p>
@kbxian
kbxian / collections.liquid
Created April 16, 2018 07:02
Add filter to Shopify collection page
<div class="custom-filter-div">
<label for="custom-filter-by">Filter By</label>
<select name="custom-filter-by" class="custom-filter-by" style="width: 100%; font-size: 15px; line-height: 15px; cursor: pointer; background: #ededed; text-align: left; -webkit-appearance: none; padding: 10px 50px 10px 20px; border-radius: 0; border: 0;">
<option value="">{{ 'collections.filtering.all' | t }}</option>
{% for tag in collection.all_tags %}
{% if current_tags contains tag %}
<option value="{{ tag | handle }}" selected>{{ tag }}</option>
{% else %}
<option value="{{ tag | handle }}">{{ tag }}</option>
{% endif %}
@kbxian
kbxian / theme.liquid
Created April 16, 2018 07:03
Add filter to Shopify colections page
<script>
jQuery('select[name=custom-filter-by]').on('change', function() {
var thisfilter = jQuery('select[name=custom-filter-by]').val();
jQuery('select[name=custom-filter-by] option[value="'+thisfilter+'"]').attr('selected','selected');
});
jQuery('select[name=custom-sort-by]').on('change', function() {
var thissort = jQuery('select[name=custom-sort-by]').val();
jQuery('select[name=custom-sort-by] option[value="'+thissort+'"]').attr('selected','selected');
});
/* Product Tag Filters - Good for any number of filters on any type of collection pages */