Skip to content

Instantly share code, notes, and snippets.

View robertdevore's full-sized avatar
🐺
#LoneWolfLifestyle

Robert DeVore robertdevore

🐺
#LoneWolfLifestyle
View GitHub Profile
@robertdevore
robertdevore / ddwc-endpoint-title-filter.php
Last active December 2, 2019 20:25
Change the "Driver Dashboard" endpoint title for the WooCommerce menu items
<?php
/**
* Change "Driver Dashboard" endpoint title
*
* @return string
*/
function acme_endpoint_title() {
return esc_attr__( 'NEW TITLE HERE', 'acme-lang' );
}
add_filter( 'ddwc_my_account_menu_item_driver_dashboard', 'acme_endpoint_title' );
@robertdevore
robertdevore / ddwc-assigned-orders-order-details-url.php
Created October 4, 2019 19:08
Filter the Assigned Orders table Order URL
<?php
/**
* Order details URL
*
* Change the order details URL that is used on the Driver Dashboard, inside
* of the assigned orders table.
*/
function acme_driver_dashboard_assigned_orders_order_details_url( $url, $orderid ) {
$url = 'YOUR_URL_HERE';
@robertdevore
robertdevore / age-verification-redirect-on-fail-filter.php
Created September 26, 2019 20:27
Change the URL for the Age Verification plugin's redirect on fail (user selects NO button)
<?php
/**
* Redirect users who select "NO" in the age verification pop up.
*/
function acme_avwp_redirect_on_fail_link( $redirect_fail ) {
$redirect_fail = 'https://yoururlhere.com';
return $redirect_fail;
}
@robertdevore
robertdevore / ddwc-delivery-text-google-map.php
Last active July 29, 2019 17:54
Add the delivery address as text on the driver details page along with the Google Map
/**
* Add delivery address as plain text above the Google Map on driver's order details page
*/
function acme_delivery_address_google_map( $google_map, $delivery_address, $store_address ) {
// Append delivery address to Google Map.
$google_map = '<p>' . $delivery_address . '</p>' . $google_map;
echo $google_map;
}
add_filter( 'ddwc_delivery_address_google_map', 'acme_delivery_address_google_map', 10, 3 );
@robertdevore
robertdevore / remove-details-from-ddwc-dashboard.php
Created July 24, 2019 16:38
Remove specific order details from the Driver Dashboard
<?php
/**
* Remove data from order details
*/
add_filter( 'ddwc_driver_dashboard_delivery_total', '__return_false' );
add_filter( 'ddwc_driver_dashboard_order_total', '__return_false' );
add_filter( 'ddwc_driver_dashboard_total_title', '__return_false' );
add_filter( 'ddwc_driver_dashboard_order_item_price', '__return_false' );
add_filter( 'ddwc_driver_dashboard_payment_method', '__return_false' );
add_filter( 'ddwc_driver_dashboard_assigned_orders_total_title', '__return_false' );
@robertdevore
robertdevore / ddwc-unclaimed-orders-my-account-menu-link.php
Last active July 22, 2019 22:36
Add unclaimed orders link to WooCommerce My Account menu items
<?php
/**
* Filters the link text of the header logo above the login form.
*
* @since 5.2.0
*
* @param string $login_header_text The login header logo link text.
*/
$login_header_text = apply_filters( 'login_headertext', $login_header_text );
@robertdevore
robertdevore / woocommerce-add-product-to-order.php
Last active May 27, 2019 23:47
Add a product to an order in WooCommerce programatically
<?php
// Get order data.
$order = wc_get_order( 1246 );
// Order total.
$total = $order->get_total();
// Add Product data.
$product_id = 8;
$quantity = 1;
@robertdevore
robertdevore / woocommerce-custom-shipping-method.php
Created March 3, 2019 18:46 — forked from malkafly/woocommerce-custom-shipping-method.php
Adding custom shipping method for WooCommerce (v. 3.2.6)
<?php
//Works with WooCommerce 3.2.6
add_action( 'woocommerce_shipping_init', 'econt_shipping_method' );
function econt_shipping_method() {
if ( ! class_exists( 'WC_Econt_Shipping_Method' ) ) {
class WC_Econt_Shipping_Method extends WC_Shipping_Method {
public function __construct( $instance_id = 0 ) {
$this->instance_id = absint( $instance_id );
$this->id = 'econt';//this is the id of our shipping method
@robertdevore
robertdevore / ddwc-driver-application-filter.php
Created January 14, 2019 20:24
Filter the text displayed for the "apply to become a driver" page
<?php
/**
* Driver Dadshboard - Access Denied Filter
*/
function acme_access_denied( $access_denied ) {
if ( false !== get_option( 'ddwc_pro_settings_driver_application' ) && 'yes' == get_option( 'ddwc_pro_settings_driver_application' ) ) {
if ( false !== get_option( 'ddwc_pro_settings_contact_page' ) && 'none' !== get_option( 'ddwc_pro_settings_contact_page' ) ) {
$contact_link = get_permalink( get_option( 'ddwc_pro_settings_contact_page' ) );
} else {
$contact_link = 'mailto:' . get_option( 'admin_email' );