Created
December 17, 2020 05:03
-
-
Save vanpariyar/2a62002e07bf4428ffd3824cd6e31b23 to your computer and use it in GitHub Desktop.
How To make custom variables for the Automate woo
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 | |
add_filter( 'automatewoo/variables', 'automatewoo_custom_variable' ); | |
function automatewoo_custom_variable( $variables ) { | |
/** | |
* Add Path of the file create folder in the theme file and see below file location. | |
*/ | |
$variables['order']['veriable_name'] = require_once get_theme_file_path().'/automatewoo/includes/variables/order-variable-name.php'; | |
return $variables; | |
} |
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 AutomateWooPayfastTokenVariable extends AutomateWoo\Variable { | |
protected $name = 'order.custom_variable'; | |
public $use_fallback = false; | |
function load_admin_details() { | |
$this->description = __( 'Genenrate a custom variable', 'automatewoo'); | |
parent::load_admin_details(); | |
} | |
/** | |
* @param $order WC_Order | |
* @param $parameters array | |
* @return string|false | |
*/ | |
public function get_value( $order, $parameters ) { | |
$custom_meta_value = get_post_meta($order->get_id(), '_custom_meta_key', true); | |
if ( empty( $custom_meta_value ) ) { | |
return false; | |
} | |
return $custom_meta_value; | |
} | |
} | |
return new AutomateWooPayfastTokenVariable(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment