Skip to content

Instantly share code, notes, and snippets.

View tharlab's full-sized avatar
💭
I may be slow to respond.

Hary AK tharlab

💭
I may be slow to respond.
  • TharLab
  • east java
View GitHub Profile
@tharlab
tharlab / mycred-history-woo-my-account
Created February 19, 2019 12:04 — forked from gabrielmerovingi/mycred-history-woo-my-account
myCRED history in WooCommerce "My Account" with pagination.
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
/**
@tharlab
tharlab / myCRED Pay on Completed or Shipped Orders
Created February 19, 2019 12:05 — forked from gabrielmerovingi/myCRED Pay on Completed or Shipped Orders
By default, myCRED pays out profit shares of WooCommerce orders when the order has been paid. This is an example of how to move the payout process so it's payed out when the order has been marked as "Completed" or "Shipped". Requires the myCRED Gateways "Profit Sharing" value to be set to zero!
/**
* Pay Sale Profit on Completed or Shipped Orders
* @version 1.0
*/
add_action( 'woocommerce_order_status_completed', 'mycred_pro_pay_profit_from_sale' );
add_action( 'woocommerce_order_status_shipped', 'mycred_pro_pay_profit_from_sale' );
function mycred_pro_pay_profit_from_sale( $order_id ) {
// Get current user id
$cui = get_current_user_id();
@tharlab
tharlab / reward-woo-owners-with-points
Created February 19, 2019 12:08 — forked from gabrielmerovingi/reward-woo-owners-with-points
For each completed WooCommerce order, give the product author 1 point for each product they sell. If the order is refunded, take those points away. Note that this will only run once per order.
/**
* Reward Store Sales
* @version 1.0
*/
function mycred_pro_reward_store_sales( $order_id ) {
// Prevent crashes if myCRED gets disabled
if ( ! function_exists( 'mycred' ) ) return;
// Get order
@tharlab
tharlab / mycred-woo-price-append
Created February 19, 2019 12:36 — forked from gabrielmerovingi/mycred-woo-price-append
Append the product price in points to WooCommerce products.
/**
* Show Cost in Points
* Show the cost of a product in points next to the regular price.
* @version 1.0
*/
function mycred_pro_append_point_price( $rendered_price, $product ) {
if ( $product->get_price() > 0 ) {
$price = $product->get_price();
@tharlab
tharlab / mycred-points-history-in-woo
Created February 19, 2019 12:37 — forked from gabrielmerovingi/mycred-points-history-in-woo
Example of how you can add a dedicated points history page in WooCommerce's My Account page.
/**
* Add Points Endpoint
* @version 1.0
*/
function mycred_pro_add_points_history_to_woo( $items ) {
$items['points'] = 'Points History';
return $items;
@tharlab
tharlab / mycred-notifications-note-filter-example
Created February 19, 2019 12:38 — forked from gabrielmerovingi/mycred-notifications-note-filter-example
Adds support for use of shortcodes in notifications.
/**
* Render Shortcodes in Notifications
* @version 1.0
*/
function mycred_pro_render_shortcodes_in_notice( $notice ) {
return do_shortcode( $notice );
}
add_filter( 'mycred_notifications_note', 'mycred_pro_render_shortcodes_in_notice' );
@tharlab
tharlab / reward-completed-woo-orders
Created February 19, 2019 12:38 — forked from gabrielmerovingi/reward-completed-woo-orders
Example: Reward buyer with 1 point for each product in an order, once the order is marked as completed. Requires WooCommerce 3.0+
/**
* Reward Completed Orders
* Will give a user 1 point for each product in an order.
* @version 1.0.1
*/
function mycred_pro_reward_completed_orders( $order_id ) {
if ( ! function_exists( 'mycred' ) ) return;
$order = wc_get_order( $order_id );
@tharlab
tharlab / reward-mycred-payment
Created February 19, 2019 12:39 — forked from gabrielmerovingi/reward-mycred-payment
By default, myCRED will not reward points if an order in WooCommerce was paid with points. This is how you override this and force myCRED to payout anyways.
add_filter( 'mycred_woo_reward_mycred_payment', '__return_true' );
@tharlab
tharlab / th_shipping_options.php
Created February 20, 2019 23:47 — forked from VjWoo/th_shipping_options.php
Shipping Options plugin
<?php
/*
Plugin Name: TH Shipping Options
Plugin URI: NA
Description: TH Shipping Options plugin
Version: 1.0.0
Author: Vj
Author URI: www.wooforce.com
*/
@tharlab
tharlab / flywheel-local-xdebug-vscode.md
Created April 18, 2019 03:45 — forked from ahmadawais/flywheel-local-xdebug-vscode.md
Debug WordPress with Visual Studio Code | VSCode WordPress Debug Setup | WordPress xDebug Setup for Local by FlyWheel with VSCode | Part of the VSCode Learning Course → https://VSCode.pro

VSCode WordPress Debugging Setup: WordPress Xdebug Setup for Local by FlyWheel with VSCode


Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User

🚅 TL;DR

  • Make sure your Local by FlyWheel WordPress install is a custom install