function wppizza_custom_order_status()
{
    $orderStatus = wppizza_order_status_default('keys');
    /**allow filtering**/
    $orderStatus = apply_filters('wppizza_filter_order_status', $orderStatus);
    $setOrderStatus = array();
    foreach ($orderStatus as $oStatus) {
        $setOrderStatus[] = wppizza_validate_alpha_only(str_replace(" ", "_", strtoupper($oStatus)));
    }
    $newOrderStatus = array_unique($setOrderStatus);
    return $newOrderStatus;
}
 //initialize array
 $options['order']['currency'] = strtoupper($input['order']['currency']);
 //validation a bit overkill, but then again, why not
 $displayCurrency = wppizza_currencies($input['order']['currency'], true);
 $options['order']['currency_symbol'] = $displayCurrency['val'];
 $options['order']['orderpage'] = !empty($input['order']['orderpage']) ? (int) $input['order']['orderpage'] : false;
 $options['order']['orderpage_exclude'] = !empty($input['order']['orderpage_exclude']) ? true : false;
 $options['order']['order_pickup'] = !empty($input['order']['order_pickup']) ? true : false;
 $options['order']['order_pickup_alert'] = !empty($input['order']['order_pickup_alert']) ? true : false;
 $options['order']['order_pickup_alert_confirm'] = !empty($input['order']['order_pickup_alert_confirm']) ? true : false;
 $options['order']['order_pickup_discount'] = wppizza_validate_float_pc($input['order']['order_pickup_discount']);
 $options['order']['order_min_for_delivery'] = wppizza_validate_float_only($input['order']['order_min_for_delivery']);
 $options['order']['order_min_for_pickup'] = wppizza_validate_float_only($input['order']['order_min_for_pickup']);
 $options['order']['order_pickup_display_location'] = wppizza_validate_int_only($input['order']['order_pickup_display_location']);
 $options['order']['delivery_selected'] = wppizza_validate_alpha_only($input['order']['delivery_selected']);
 $options['order']['discount_selected'] = wppizza_validate_alpha_only($input['order']['discount_selected']);
 $options['order']['delivery'] = array();
 foreach ($input['order']['delivery'] as $k => $v) {
     foreach ($v as $l => $m) {
         if ($l != 'deliver_below_total') {
             $options['order']['delivery'][$k][$l] = wppizza_validate_float_only($m, 2);
         }
     }
     if ($k == 'minimum_total') {
         $options['order']['delivery'][$k]['deliver_below_total'] = !empty($input['order']['delivery'][$k]['deliver_below_total']) ? true : false;
         $options['order']['delivery'][$k]['deliverycharges_below_total'] = wppizza_validate_float_only($input['order']['delivery'][$k]['deliverycharges_below_total']);
     }
 }
 /**hardcode no_delivery (as there are  no submitted input values)*/
 $options['order']['delivery']['no_delivery'] = '';
 $options['order']['discounts'] = array();
Example #3
0
 function wppizza_set_order_status()
 {
     $setStatus = wppizza_custom_order_status();
     /**compare and see if we have to do anything**/
     if ($this->pluginOptions != 0 && (!isset($this->pluginOptions['plugin_data']['db_order_status_options']) || $this->pluginOptions['plugin_data']['db_order_status_options'] != $setStatus)) {
         global $wpdb;
         $usedOrderStatus = $wpdb->get_col("SELECT DISTINCT(order_status) FROM " . $wpdb->prefix . $this->pluginOrderTable . " ");
         $newStatus = array();
         foreach ($setStatus as $k => $v) {
             $newStatus[] = wppizza_validate_alpha_only(str_replace(" ", "_", strtoupper($v)));
         }
         /**implicitly add all options already in use**/
         foreach ($usedOrderStatus as $k => $v) {
             $newStatus[] = wppizza_validate_alpha_only(str_replace(" ", "_", strtoupper($v)));
         }
         /**implicitly add NEW option (as its default)*****/
         $newStatus[] = 'NEW';
         /**update options**/
         $update_options = $this->pluginOptions;
         $update_options['plugin_data']['db_order_status_options'] = $setStatus;
         update_option($this->pluginSlug, $update_options);
         /**ALTER TABLE**/
         $setNewOrderStatus = array_unique($newStatus);
         require_once WPPIZZA_PATH . 'inc/admin.create.order.table.inc.php';
     }
 }
 function wppizza_gateway_order_completed($orderhash, $blogid = false, $txtPending = false, $txtCancelled = false, $content = false, $refresh = 5000, $transaction_errors = false)
 {
     $orderhash = wppizza_validate_alpha_only($orderhash);
     /**sanitize**/
     $res = $this->wppizza_gateway_get_order_details($orderhash, false, $blogid);
     $markup = '';
     if ($res) {
         /**done**/
         if ($res->payment_status == 'COMPLETED') {
             $markup .= "<div class='wppizza-gateway-success'><h1>" . $this->pluginOptions['localization']['thank_you']['lbl'] . "</h1>" . nl2br($this->pluginOptions['localization']['thank_you_p']['lbl']) . "</div>";
             /**display order details (if enabled)**/
             //$markup.="".$this->gateway_order_on_thankyou($res->id,$this->pluginOptions);
             /**display order details (if enabled)**/
             ob_start();
             $this->gateway_order_on_thankyou($res->id, $this->pluginOptions);
             $markup .= ob_get_clean();
             /*legacy for gateways that print as opposed to return output in filter*/
             if (!$content) {
                 echo $markup;
                 return;
             } else {
                 return $markup;
             }
         }
         /**waiting for ipn response**/
         if (in_array($res->payment_status, array('CAPTURED', 'AUTHORIZED', 'PENDING'))) {
             $markup .= "<div class='wppizza-gateway-success'>" . $txtPending . "<p><b>ID:" . $res->id . "</b></p></div>";
             $markup .= '<script>setInterval(function(){window.location.href=window.location.href;},' . $refresh . ');</script>';
             /*legacy for gateways that print as opposed to return output in filter*/
             if (!$content) {
                 echo $markup;
                 return;
             } else {
                 return $markup;
             }
         }
         /**cancelled**/
         if ($res->payment_status == 'CANCELLED') {
             /*maybe redirect to orderpage without GET vars or homepage ??*/
             $markup .= "<div class='wppizza-gateway-success'>" . $txtCancelled . "</div>";
             /*legacy for gateways that print as opposed to return output in filter*/
             if (!$content) {
                 echo $markup;
                 return;
             } else {
                 return $markup;
             }
         }
         /**failed and set to display specific errors - perhaps one day something like that**/
         //			if($res->payment_status=='FAILED' && $transaction_errors){
         //				$errors='<br />';
         //				$errors.="ORDER ID: ".$res->id."<br />";
         //				$errors.="TRANSACTION ID: ".$res->transaction_id."<br />";
         //				$errors.="TRANSACTION STATUS: ".$res->payment_status."<br />";
         //				/*as array*/
         //				if(is_array($transaction_errors) && count($transaction_errors>0)){
         //				foreach($transaction_errors as $error){
         //					$errors.='<br />'.$error;
         //				}}else{
         //
         //					$errors.=''.$transaction_errors;
         //				}
         //				$markup.="<div class='wppizza-gateway-failed'>payment failed [".$this->gatewayIdent."-1200]: ".$errors."</div>";
         //
         //				/*legacy for gateways that print as opposed to return output in filter*/
         //				if(!$content){echo $markup;return;}else{return $markup;}
         //			}
         /**all others**/
         //$errors="ORDER ID: ".$res->id."<br />";
         //$errors.="TRANSACTION ID: ".$res->transaction_id."<br />";
         //$errors.="TRANSACTION STATUS: ".$res->payment_status."<br />";
         //".nl2br(print_r(unserialize($res->transaction_errors),true))."
         //print"<div class='wppizza-gateway-error'>error [".$this->gatewayIdent."-1101]: ".__('Sorry, there was an error processing your order. please contact us, providing the details below !',$this->pluginLocale)."<br /><br />".$errors."</div>";
         /**actually lets make this a generic page without too much info**/
         $markup .= "<div class='wppizza-gateway-error'>error [" . $this->gatewayIdent . "-1102]: " . __('Sorry, this order has already been processed or does not exist !', $this->pluginLocale) . "</div>";
         /*legacy for gateways that print as opposed to return output in filter*/
         if (!$content) {
             echo $markup;
             return;
         } else {
             return $markup;
         }
     } else {
         $markup .= "<div class='wppizza-gateway-error'>error [" . $this->gatewayIdent . "-1103]: " . __('Sorry, this order does not exist !', $this->pluginLocale) . "</div>";
         /*legacy for gateways that print as opposed to return output in filter*/
         if (!$content) {
             echo $markup;
             return;
         } else {
             return $markup;
         }
     }
     if (!$content) {
         return;
     } else {
         return $content;
     }
 }