Last active
July 5, 2018 13:22
-
-
Save hxii/cf57d4d5a4e69f38fc33402dd9a777c9 to your computer and use it in GitHub Desktop.
Custom Order Status support for Yotpo's WooCommerce Plugin
This file contains 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
<? | |
// Main function | |
// has to be added to wc-yotpo-settings.php | |
function wc_yotpo_get_orderstatus($setting) { | |
// $setting is current order status as saved in the settings | |
$statuses = wc_get_order_statuses(); | |
if (!array_key_exists($setting,$statuses)) { | |
wc_yotpo_display_message('Warning - The current Custom Order Status setting ('.$setting.') does <strong>NOT</strong> exist in your WooCommerce instance. <br>It is recommended that you update your settings to avoid missing orders!', true); | |
} elseif (is_null($setting) || empty($setting)) { | |
wc_yotpo_display_message('Warning - The current Custom Order Status setting is <strong>NULL</strong>. <br>It is recommended that you update your order status setting to avoid missing orders!', true); | |
} | |
$html = '<select name="yotpo_order_status" class="yotpo-order-status" id="order-status">'; | |
foreach ($statuses as $k => $v) { | |
$html .= '<option value="'.$k.'"'.selected($k, $setting, false).'>'.$v.'</option>'; | |
} | |
$html .= '</select>'; | |
return $html; | |
} | |
// Change HTML from the usual hardcoded stuff and call the function wc_yotpo_get_orderstatus($yotpo_settings['yotpo_order_status']) | |
// Example: | |
// <tr valign='top'> | |
// <th scope='row'><div>Order Status:</div></th> | |
// <td> | |
// ".wc_yotpo_get_orderstatus($yotpo_settings['yotpo_order_status'])." | |
// </td> | |
// </tr> | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment