This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Defining a connection in Query Builder | |
$data = DB::connection('mysql_second') | |
->table('table_name') | |
->select('col_1') | |
->get(); | |
//Defining a connection within the Schema Builder. | |
Schema::connection('mysql_second')->create('table_name', function($table) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyModel extends Eloquent { | |
//... | |
protected $connection = 'mysql_second'; | |
//... | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//create an instance of your model | |
$objMyModel = new MyModel(); | |
//query for fetching data | |
$data = $objMyModel->setConnection('mysql_second') | |
->select('col_1') | |
->get(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('getOrderDetailById')) { | |
//to get full order details | |
function getOrderDetailById($id, $fields = null, $filter = array()) { | |
if (is_wp_error($id)) | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('getOrderDetailById')) { | |
function getOrderDetailById($id, $fields = null, $filter = array()) { | |
if (is_wp_error($id)) | |
return $id; | |
// Get the decimal precession |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$order_detail = getOrderDetailById(101); //to get the detail of order ID #101 | |
print_r($order_detail); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$order_id = method_exists($order, 'get_id') ? $order->get_id() : $order->id; | |
//getting shipping details | |
$objWC_Shipment = WC_Shipment_Tracking_Actions::get_instance(); | |
$shipping_details = $objWC_Shipment->get_tracking_items($order_id); | |
if (!empty($shipping_details)) { | |
foreach ($shipping_details as $shipping_detail) { | |
$order_data['shipping_details'][] = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$order_id = method_exists($order, 'get_id') ? $order->get_id() : $order->id; | |
//getting shipping details | |
$tracking_number = get_post_meta($order_id, '_tracking_number', TRUE); | |
if (isset($tracking_number) && !empty($tracking_number)) { | |
$order_data['shipping_details'] = array( | |
'tracking_provider' => get_post_meta($order_id, '_tracking_provider', TRUE), | |
'tracking_number' => $tracking_number, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"keys": ["ctrl+alt+c"], | |
"command": "copy_path" | |
}, | |
{ | |
"keys": ["shift+command+m"], | |
"command": "goto_definition" | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.`ID`, | |
p.`post_title` AS coupon_code, | |
p.`post_excerpt` AS coupon_description, | |
Max(CASE WHEN pm.meta_key = 'discount_type' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS discount_type, -- Discount type | |
Max(CASE WHEN pm.meta_key = 'coupon_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS coupon_amount, -- Coupon amount | |
Max(CASE WHEN pm.meta_key = 'free_shipping' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS free_shipping, -- Allow free shipping | |
Max(CASE WHEN pm.meta_key = 'expiry_date' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS expiry_date, -- Coupon expiry date | |
Max(CASE WHEN pm.meta_key = 'minimum_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS minimum_amount, -- Minimum spend | |
Max(CASE WHEN pm.meta_key = 'maximum_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS maximum_amount, -- Maximum spend | |
Max(CASE WHEN pm.m |