Skip to content

Instantly share code, notes, and snippets.

View ChrisFlannagan's full-sized avatar

Chris Flannagan ChrisFlannagan

View GitHub Profile
<?php
namespace Project\WooCommerce\Gateways;
class Estimates extends \WC_Payment_Gateway {
const ID = 'estimates-gateway';
const WC_STATUS = 'wc-estimate';
public function __construct() {
<?php
unload_textdomain( 'woocommerce' );
WC()->countries->states = null;
WC()->countries->load_country_states();
$formatted_address = WC()->countries->get_formatted_address( $address );
WC()->load_plugin_textdomain();
WC()->countries->load_country_states();
//$formatted_address was now in English!
<?php
add_action( 'woocommerce_checkout_create_order', function( $order, $data ) {
// For my example I only want to do this on payments through cash on delivery gateway
// This is not a requirement though, you can do it for any reason you want.
if ( $order->get_payment_method() !== 'cod' ) {
return;
}
// I get my fee from the COD gateway settings field we added
<?php
add_filter( 'woocommerce_settings_api_form_fields_cod', function( $form_fields ) {
$form_fields[ 'custom_fee' ] = [
'title' => __( 'Fee in $', 'textdomain' ),
'type' => 'number',
'description' => __( 'Add a fee to orders using Cash on Delivery gateway.', 'textdomain' ),
'default' => 0,
'min' => 0,
'step' => .01,
<?php
/*
Plugin Name: My Custom Plugin
<?php
/**
* @param $value
* @param $option_value
*/
function my_special_field( $value, $option_value ) {
?>
<tr>
<th scope="row" class="titledesc" colspan="2">
<input type="text" name="my_special_field" value="<?php esc_attr( give_get_option( 'my_special_field' ); ?>" />
<?php
/**
* @param $value
* @param $option_value
*/
function my_custom_subtitle( $value, $option_value ) {
?>
<tr>
<th scope="row" class="titledesc" colspan="2">
var enumsModule = require("ui/enums");
var cameraModule = require("camera");
var fs = require('file-system');
var bghttp = require("nativescript-background-http");
exports.takephoto = function(args) {
cameraModule.takePicture({width: 800, height: 800, keepAspectRatio: true}).then(function(picture) {
var savepath = fs.knownFolders.currentApp().path + "/saved_images";
var filename = 'img_' + new Date().getTime() + '.jpg';
var filepath = fs.path.join(savepath, filename);
ropeObject.getHolder().addChildNode(ropeObject.getRope())
links.forEach { link in
ropeObject.getHolder().addChildNode( link )
}
/** Generate our rope links **/
var cnt:Float = 0.0
var previousLink: SCNNode = ropeObject.getRope()
var links :[SCNNode] = [SCNNode]()
while cnt < 2.0 {
let link = ropeObject.getLink( y: Float(cnt) )
links.append(link)
let joint = SCNPhysicsBallSocketJoint(
bodyA: link.physicsBody!,