Пример #1
0
" <?php 
                echo !empty($elm['required']) ? 'required' : '';
                ?>
>
						<option value=""><?php 
                echo !empty($elm['placeholder']) ? '' . $elm['placeholder'] . '' : '--------';
                ?>
</option>
						<?php 
                foreach ($elm['value'] as $a => $b) {
                    ?>
						<option value="<?php 
                    echo wppizza_validate_string($b);
                    ?>
" <?php 
                    echo !empty($elm['prefill']) && isset($userMeta[$elm['key']]) && $userMeta[$elm['key']] == wppizza_validate_string($a) ? 'selected="selected"' : '';
                    ?>
><?php 
                    echo $b;
                    ?>
</option>
						<?php 
                }
                ?>
					</select>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
Пример #2
0
 function wppizza_sessionise_userdata($postUserData, $orderFormOptions)
 {
     if (!session_id()) {
         session_start();
     }
     $params = array();
     parse_str($postUserData, $params);
     /**selects are zero indexed*/
     foreach ($orderFormOptions as $elmKey => $elm) {
         if ($elm['type'] == 'select' && isset($params[$elm['key']])) {
             foreach ($elm['value'] as $a => $b) {
                 if ($params[$elm['key']] == $b) {
                     $params[$elm['key']] = '' . $a . '';
                 }
             }
         }
     }
     /******************************************
     				[get entered data to re-populate input fields but loose irrelevant vars
     			********************************************/
     /**empty first and start over**/
     if (isset($_SESSION[$this->pluginSessionGlobal]['userdata'])) {
         unset($_SESSION[$this->pluginSessionGlobal]['userdata']);
     }
     foreach ($orderFormOptions as $oForm) {
         if ($oForm['key'] != 'ctips') {
             /**tips should not be in the global user session**/
             if (isset($params[$oForm['key']])) {
                 $_SESSION[$this->pluginSessionGlobal]['userdata'][$oForm['key']] = $params[$oForm['key']];
             }
         }
     }
     /***eliminate notice of undefined index userdata**/
     if (!isset($_SESSION[$this->pluginSessionGlobal]['userdata'])) {
         $_SESSION[$this->pluginSessionGlobal]['userdata'] = array();
     }
     /*also keep selected gateway in session*/
     if (isset($_SESSION[$this->pluginSessionGlobal]['userdata']['gateway'])) {
         /**store previously selected in case we need to fall back to it**/
         //$prevGwFallback=$_SESSION[$this->pluginSessionGlobal]['userdata']['gateway'];
         /*unset session*/
         unset($_SESSION[$this->pluginSessionGlobal]['userdata']['gateway']);
     }
     $selectedGateway = !empty($params['wppizza-gateway']) ? strtoupper(wppizza_validate_string($params['wppizza-gateway'])) : '';
     /*reset session if not empty*/
     if ($selectedGateway != '') {
         $_SESSION[$this->pluginSessionGlobal]['userdata']['gateway'] = $selectedGateway;
     }
     /**allow filtering of session data**/
     $_SESSION[$this->pluginSessionGlobal]['userdata'] = apply_filters('wppizza_filter_sessionise_userdata', $_SESSION[$this->pluginSessionGlobal]['userdata'], $params);
     return $params;
 }
Пример #3
0
}
/********************************************
*
*
*		[order history -> update notes]
*
*
********************************************/
if ($_POST['vars']['field'] == 'ordernoteschange' && isset($_POST['vars']['id']) && $_POST['vars']['id'] >= 0) {
    global $wpdb;
    /**distinct blogid set**/
    if ($_POST['vars']['blogid'] != '') {
        $wpdb->prefix = $wpdb->prefix . $_POST['vars']['blogid'] . '_';
    }
    /*add notes to db*/
    $notes = wppizza_validate_string($_POST['vars']['selVal']);
    $res = $wpdb->query("UPDATE " . $wpdb->prefix . $this->pluginOrderTable . " SET notes='" . $notes . "' WHERE id=" . (int) $_POST['vars']['id'] . " ");
    $output = strlen($notes);
    print "" . $output . "";
    exit;
}
/*************************************************************************************
*
*
*	[order history -> print order]
*
*
*************************************************************************************/
if ($_POST['vars']['field'] == 'print-order' && $_POST['vars']['id'] >= 0) {
    $orderId = (int) $_POST['vars']['id'];
    /*should never happen really*/
Пример #4
0
*
*	[get the confirm order page]
*
*
****************************************************************************************************************************************/
if (isset($_POST['vars']['type']) && $_POST['vars']['type'] == 'confirmorder') {
    header('Content-type: text/html');
    /***************************************************************
    			[get and parse all user post variables and save in session
    		***************************************************************/
    if (count($_POST['vars']['data']) > 0) {
        $param = $this->wppizza_sessionise_userdata($_POST['vars']['data'], $options['order_form']);
        /**add hash**/
        $atts['hash'] = !empty($param['wppizza_hash']) ? wppizza_validate_string($param['wppizza_hash']) : '';
        /**add used gateway*/
        $atts['gateway'] = !empty($param['wppizza-gateway']) ? wppizza_validate_string($param['wppizza-gateway']) : '';
        /**ajax**/
        if ($_POST['vars']['hasClassAjax'] == 'true') {
            $atts['hasClassAjax'] = 1;
        }
        /**custom**/
        if ($_POST['vars']['hasClassCustom'] == 'true') {
            $atts['hasClassCustom'] = 1;
        }
    }
    ob_start();
    $this->wppizza_include_shortcode_template('confirmationpage', $atts);
    $markup = ob_get_clean();
    print "" . $markup;
    exit;
}
Пример #5
0
 function wppizza_user_register_order_page($user_id, $password = '', $meta = array())
 {
     $ff = $this->pluginOptions['order_form'];
     $ff = apply_filters('wppizza_filter_formfields_register_save_onorder', $ff);
     foreach ($ff as $field) {
         if (!empty($field['enabled']) && $field['type'] != 'cemail' && $field['type'] != 'tips') {
             /**selects should be stored by index**/
             if ($field['type'] == 'select') {
                 $sanitizeInput = array_search($_POST[$field['key']], $field['value']);
             } else {
                 $sanitizeInput = wppizza_validate_string($_POST[$field['key']]);
             }
             update_user_meta($user_id, 'wppizza_' . $field['key'], $sanitizeInput);
         }
     }
     /**turn off admin bar by default**/
     update_user_meta($user_id, 'show_admin_bar_front', 'false');
 }
 function wppizza_order_email($orderid, $blogid = false)
 {
     global $wpdb;
     /**select the right blog table */
     if ($blogid && is_int($blogid) && $blogid > 1) {
         $wpdb->prefix = $wpdb->base_prefix . $blogid . '_';
     }
     $res = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . $this->pluginOrderTable . " WHERE id='" . $orderid . "' ");
     /*initialize vars**/
     if ($res) {
         /*********************************************************************
          *
          *
          *	get and filter customer and order details as required
          *
          *
          **********************************************************************/
         /*cutstomer details**/
         $cDetails = maybe_unserialize($res->customer_ini);
         /****************************************************************
         				include wpml to also send store/emails translated.
         				will not affect items (they will always be the translated one's
         				or - more accurately - be the ones that were put in the cart
         				don't use require once
         			****************************************************************/
         /**set appropriate language. as this can be a language agnostic ipn request, set it specifically depending on what was stored in the db**/
         if (function_exists('icl_translate') && isset($cDetails['wppizza_wpml_lang']) && $cDetails['wppizza_wpml_lang'] != '') {
             global $sitepress;
             /*polylang for instance does not recognise switch_lang*/
             if (method_exists($sitepress, 'switch_lang')) {
                 $sitepress->switch_lang($cDetails['wppizza_wpml_lang']);
             }
             require WPPIZZA_PATH . 'inc/wpml.inc.php';
             require WPPIZZA_PATH . 'inc/wpml.gateways.inc.php';
         }
         /***get (possibly wpml'ed) options**/
         $pOptions = $this->pluginOptions;
         /*order details: unserialize and filter**/
         $oIni = maybe_unserialize($res->order_ini);
         $oDetails = apply_filters('wppizza_filter_order_db_return', $oIni);
         /*********************************************************************
          *
          *		[currency position]
          *
          *********************************************************************/
         $currency_left = wppizza_email_decode_entities($oDetails['currency'], $this->blogCharset) . ' ';
         $currency_right = '';
         if ($this->pluginOptions['layout']['currency_symbol_position'] == 'right') {
             /*right aligned*/
             $currency_left = '';
             $currency_right = ' ' . wppizza_email_decode_entities($oDetails['currency'], $this->blogCharset);
         }
         /*********************************************************************
          *
          *		[update user meta data]
          *
          *********************************************************************/
         if ($res->wp_user_id > 0) {
             /**update profile**/
             if (!empty($oIni['update_profile'])) {
                 $ff = $pOptions['order_form'];
                 $ff = apply_filters('wppizza_filter_formfields_update_profile', $ff);
                 foreach ($ff as $field) {
                     if (!empty($field['enabled'])) {
                         if ($field['type'] != 'select') {
                             update_user_meta($res->wp_user_id, 'wppizza_' . $field['key'], wppizza_validate_string($cDetails[$field['key']]));
                             /*we've validated already, but lets just be save*/
                         } else {
                             $selKey = array_search($cDetails[$field['key']], $field['value']);
                             update_user_meta($res->wp_user_id, 'wppizza_' . $field['key'], $selKey);
                         }
                     }
                 }
                 /**also update WP email...hmmm better not*/
                 //if(!empty($field['enabled']) && $field['key']=='cemail' && !empty($cDetails['cemail'])) {
                 //	wp_update_user( array ( 'ID' => $res->wp_user_id, 'user_email' => $cDetails['cemail'] ) ) ;
                 //}
             }
             /**the below isnt really needed anymore, but - for legacy reasons - let's keep it for the moment*/
             $userMeta = $cDetails;
             /*tidy up a bit*/
             if ($userMeta['wppizza-gateway']) {
                 unset($userMeta['wppizza-gateway']);
             }
             if ($userMeta['wppizza_hash']) {
                 unset($userMeta['wppizza_hash']);
             }
             if (isset($userMeta['update_profile'])) {
                 unset($userMeta['update_profile']);
             }
             update_user_meta($res->wp_user_id, 'wppizza_user_meta', $userMeta);
         }
         /*********************************************************************
          *
          *
          *	customer details : posted and stored variables from order page
          *
          *
          **********************************************************************/
         /*********************************************
          *	[posted input fields of this plugin]
          *********************************************/
         $wppizzaEmailCustomerDetails = array();
         /**protect these keys, so no other extension uses it*/
         $protectedKeys = array();
         foreach ($this->pluginOptions['order_form'] as $k => $v) {
             $protectedKeys[$v['key']] = $v;
         }
         $protectedKeys = apply_filters('wppizza_filter_order_form_fields', $protectedKeys);
         $i = 0;
         foreach ($cDetails as $k => $v) {
             /*****default input fields of this plugin*****/
             if (isset($protectedKeys[$k])) {
                 $wppizzaEmailCustomerDetails[] = array('label' => $protectedKeys[$k]['lbl'], 'value' => $cDetails[$k], 'type' => $protectedKeys[$k]['type'], 'key' => $k);
             }
             /**********************************************************************************************************
              *
              *
              *	THIS BIT BELOW SHOULD NOW BE REDUNDANT NOW AS WE CAN UST USE THE FILTER ABOVE TO ADD TO THE - SO CALLED - PROTECTED KEYS
              *	let's leave it here for now, but it will probably be removed in future versions, as it has never been documnted publicly anyway
              *	as far as i know......
              *
              **********************************************************************************************************/
             /*********************************************************************
             				if another plugin/extension wants to add field value pairs, make sure
             				its an array having [label] and [value] to display in email
             				i.e:
             				<input type="hidden" name="distinct_name[label]" value="some value"/>';
             				<input type="text" name="distinct_name[value]" value="some value"/>';
             				(make sure there are no clashes with other input fields)
             				ought to make this "classable" at some point anyway
             			**********************************************************************/
             if (!isset($protectedKeys[$k])) {
                 if (is_array($v) && isset($v['label']) && isset($v['value']) && !isset($protectedKeys[$k])) {
                     $wppizzaEmailCustomerDetails[] = array('label' => $v['label'], 'value' => $v['value'], 'type' => 'text', 'key' => $k);
                 }
             }
         }
         /*****************************************************************************************
          *
          *
          *	[order items: individual items]
          *
          *
          ****************************************************************************************/
         $wppizzaEmailOrderItems = array();
         foreach ($oDetails['item'] as $k => $v) {
             $wppizzaEmailOrderItems[$k] = $v;
             /**for convenience, we concat vars into label and value and add them to array */
             $wppizzaEmailOrderItems[$k]['label'] = '' . $v['quantity'] . 'x ' . $v['name'] . ' ' . $v['size'] . ' [' . $currency_left . '' . $v['price'] . '' . $currency_right . ']';
             $wppizzaEmailOrderItems[$k]['value'] = '' . $currency_left . $v['pricetotal'] . $currency_right . '';
         }
         /**********************************************************************************************
          *
          *
          *	[order summary]
          *	--we can probably loose all the currencies here. oh well. who knows maybe useful one day
          *
          *********************************************************************************************/
         $wppizzaEmailOrderSummary = array();
         /**********************************************************
          *	[cart items
          **********************************************************/
         $wppizzaEmailOrderSummary['cartitems'] = array('label' => $pOptions['localization']['order_items']['lbl'], 'price' => $oDetails['total_price_items'], 'currency' => $oDetails['currency']);
         /**********************************************************
          *	[discount]
          **********************************************************/
         if ($oDetails['discount'] > 0) {
             $wppizzaEmailOrderSummary['discount'] = array('label' => $pOptions['localization']['discount']['lbl'], 'price' => $oDetails['discount'], 'currency' => $oDetails['currency']);
         }
         /**********************************************************
          *	[item tax - tax applied to items only]
          **********************************************************/
         if ($oDetails['item_tax'] > 0 && !$pOptions['order']['shipping_tax']) {
             $wppizzaEmailOrderSummary['item_tax'] = array('label' => $pOptions['localization']['item_tax_total']['lbl'], 'price' => $oDetails['item_tax'], 'currency' => $oDetails['currency']);
         }
         /**********************************************************
          *	[delivery charges - no self pickup enabled or selected]
          **********************************************************/
         if ($pOptions['order']['delivery_selected'] != 'no_delivery') {
             /*delivery disabled*/
             if (!isset($oDetails['selfPickup']) || $oDetails['selfPickup'] == 0) {
                 if ($oDetails['delivery_charges'] != '') {
                     $wppizzaEmailOrderSummary['delivery'] = array('label' => $pOptions['localization']['delivery_charges']['lbl'], 'price' => $oDetails['delivery_charges'], 'currency' => $oDetails['currency']);
                 } else {
                     $wppizzaEmailOrderSummary['delivery'] = array('label' => $pOptions['localization']['free_delivery']['lbl'], 'price' => '', 'currency' => '');
                 }
             }
         }
         /**********************************************************
          *	[item tax - tax applied to items only]
          **********************************************************/
         if ($oDetails['item_tax'] > 0 && $pOptions['order']['shipping_tax']) {
             $wppizzaEmailOrderSummary['item_tax'] = array('label' => $pOptions['localization']['item_tax_total']['lbl'], 'price' => $oDetails['item_tax'], 'currency' => $oDetails['currency']);
         }
         /**********************************************************
          *	[taxes included]
          **********************************************************/
         if ($oDetails['taxes_included'] > 0 && $pOptions['order']['taxes_included']) {
             $wppizzaEmailOrderSummary['taxes_included'] = array('label' => sprintf('' . $pOptions['localization']['taxes_included']['lbl'] . '', $pOptions['order']['item_tax']), 'price' => $oDetails['taxes_included'], 'currency' => $oDetails['currency']);
         }
         /**********************************************************
          *	[handling charges - (most likely to be used for vv payment)]
          **********************************************************/
         if (isset($oDetails['handling_charge']) && $oDetails['handling_charge'] > 0) {
             $wppizzaEmailOrderSummary['handling_charge'] = array('label' => $pOptions['localization']['order_page_handling']['lbl'], 'price' => wppizza_output_format_price($oDetails['handling_charge'], $pOptions['layout']['hide_decimals']), 'currency' => $oDetails['currency']);
         }
         /**********************************************************
          *	[tips )]
          **********************************************************/
         if (isset($oDetails['tips']) && $oDetails['tips'] > 0) {
             $wppizzaEmailOrderSummary['tips'] = array('label' => $pOptions['localization']['tips']['lbl'], 'price' => wppizza_output_format_price($oDetails['tips'], $pOptions['layout']['hide_decimals']), 'currency' => $oDetails['currency']);
         }
         /**********************************************************
         				[order total]
         			**********************************************************/
         $wppizzaEmailOrderSummary['total'] = array('label' => $pOptions['localization']['order_total']['lbl'], 'price' => $oDetails['total'], 'currency' => $oDetails['currency']);
         /****************************************************
         				[self pickup (enabled and selected) / no delivery offered ]
         			****************************************************/
         if (isset($oDetails['selfPickup']) && $oDetails['selfPickup'] >= 1) {
             if ($oDetails['selfPickup'] == 1) {
                 $wppizzaEmailOrderSummary['self_pickup'] = array('label' => $pOptions['localization']['order_page_self_pickup']['lbl'], 'price' => '', 'currency' => '');
             }
             if ($oDetails['selfPickup'] == 2) {
                 $wppizzaEmailOrderSummary['self_pickup'] = array('label' => $pOptions['localization']['order_page_no_delivery']['lbl'], 'price' => '', 'currency' => '');
             }
         }
         /*********************************************************************************************************************************
          *
          *
          *
          *	[now lets do something with it all, like filtering etc]
          *
          *
          *
          **********************************************************************************************************************************/
         /**filter old legacy additional info keys**/
         $wppizzaEmailOrderItems = apply_filters('wppizza_filter_order_additional_info', $wppizzaEmailOrderItems);
         /**filter new/current extend additional info keys**/
         $wppizzaEmailOrderItems = apply_filters('wppizza_filter_order_extend', $wppizzaEmailOrderItems);
         /****************************************************
         				[allow filtering of summary too]
         			****************************************************/
         $wppizzaEmailOrderSummary = apply_filters('wppizza_filter_order_summary_parameters_emails', $wppizzaEmailOrderSummary, $oDetails);
         /***********************************************************************************************
          *
          *	[set the relevant class vars]
          *
          ***********************************************************************************************/
         /**********************************************
         				[all db vals - maybe useful at some point in the future]
         			************************************************/
         $this->orderResults = $res;
         /***********************************************
         				[set currency etc]
         			************************************************/
         $this->orderCurrency = $oDetails['currency'];
         $this->orderTransactionId = $res->transaction_id;
         $this->orderGatewayUsed = $res->initiator;
         /***********************************************
         				[set localization vars]
         			************************************************/
         foreach ($pOptions['localization'] as $k => $v) {
             $orderLabel['html'][$k] = $v['lbl'];
             $orderLabel['plaintext'][$k] = wppizza_email_decode_entities($v['lbl'], $this->blogCharset);
         }
         $this->orderLabels = $orderLabel;
         /************************************************************************************************************************
          *
          *	[set plaintext variables for emails and order history]
          *	lets get all the plaintext things we need, making htmldecoded strings out of customer details and summary
          *	, and htmldecoded array out of order items to be used in plaintext email template and to save into order history
          *
          ************************************************************************************************************************/
         /***********************************************
         				[set general vars]
         			************************************************/
         $gatewayUsed = $res->initiator;
         /**get gateway frontend label instead of just COD or similar**/
         $gatewayLabel = $res->initiator;
         $wppizzaGateways = new WPPIZZA_GATEWAYS();
         $this->pluginGateways = $wppizzaGateways->wppizza_instanciate_gateways_frontend();
         if (isset($this->pluginGateways[$res->initiator])) {
             $gatewayLabel = !empty($this->pluginGateways[$res->initiator]->gatewayOptions['gateway_label']) ? $this->pluginGateways[$res->initiator]->gatewayOptions['gateway_label'] : $gatewayLabel;
         }
         /**********************/
         $transactionId = $res->transaction_id;
         /**filter as required**/
         $transactionId = apply_filters('wppizza_email_filter_transaction_id', $transactionId, $res->id);
         $nowdate = $this->orderTimestamp;
         $orderLabel = $this->orderLabels['plaintext'];
         /**customer details as plaintext string: to use in plaintext emails and save into order history->customer details**/
         $emailPlaintext['customer_details'] = apply_filters('wppizza_filter_customer_details_to_plaintext', $wppizzaEmailCustomerDetails);
         /**order details as plaintext string: to use in plaintext emails and save into order history->order details**/
         $emailPlaintext['items'] = apply_filters('wppizza_filter_order_items_to_plaintext', $wppizzaEmailOrderItems);
         /**for plaintext email template**/
         /**items as string to insert into db**/
         $emailPlaintext['db_items'] = '';
         /***allow filtering of items (sort, add categories and whatnot)****/
         $emailPlaintext['items'] = apply_filters('wppizza_emailplaintext_filter_items', $emailPlaintext['items'], 'plaintextemail');
         foreach ($emailPlaintext['items'] as $k => $v) {
             /***allow action per item - probably to use in conjunction with filter above****/
             $emailPlaintext['db_items'] = apply_filters('wppizza_emailplaintext_item', $v, $emailPlaintext['db_items']);
             $strPartLeft = '' . $v['label'] . '';
             /*made up of => '.$v['quantity'].'x '.$v['name'].' '.$v['size'].' ['.$v['currency'].' '.$v['price'].']'*/
             $spaces = 75 - strlen($strPartLeft);
             $strPartRight = '' . $v['value'] . '';
             /*made up of => '.$v['currency'].' '.$v['pricetotal'].'*/
             /**add to string, spacing left and right out somewhat and put linebreak before any additional info**/
             $emailPlaintext['db_items'] .= '' . $strPartLeft . '' . str_pad($strPartRight, $spaces, " ", STR_PAD_LEFT) . PHP_EOL . '';
             /**NOTE: DO NOT DELETE OR ALTER THE ADDITIONAL INFO DECLARATIONS OR YOU MIGHT BREAK THINGS. IF NOT NOW THAN POSSIBLY IN THE FUTURE AS OTHER EXTENSIONS MAY RELY ON THIS!!!*/
             if (isset($v['additional_info']) && trim($v['additional_info']) != '') {
                 $emailPlaintext['db_items'] .= '' . $v['additional_info'] . '';
                 /**add additional line break as spacer between items**/
                 $emailPlaintext['db_items'] .= PHP_EOL;
             }
         }
         /**summary details as plaintext string: to use in plaintext emails and save into order history->order details**/
         $emailPlaintext['order_summary'] = apply_filters('wppizza_filter_order_summary_to_plaintext', $wppizzaEmailOrderSummary);
         /**include plaintext template**/
         $orderEmailPlaintext = '';
         if (file_exists($this->pluginTemplateDir . '/wppizza-order-email-plaintext.php')) {
             ob_start();
             require_once $this->pluginTemplateDir . '/wppizza-order-email-plaintext.php';
             $orderEmailPlaintext = ob_get_clean();
         } else {
             ob_start();
             require_once WPPIZZA_PATH . 'templates/wppizza-order-email-plaintext.php';
             $orderEmailPlaintext = ob_get_clean();
         }
         $this->orderMessage['plaintext'] = "" . PHP_EOL . PHP_EOL . $orderEmailPlaintext . PHP_EOL;
         /***********************************************
         				[set html email vars]
         			************************************************/
         $this->orderMessage['html']['customer_details'] = $wppizzaEmailCustomerDetails;
         $this->orderMessage['html']['order_items'] = $wppizzaEmailOrderItems;
         $this->orderMessage['html']['order_summary'] = $wppizzaEmailOrderSummary;
         /***********************************************
         				[customer and order details to be saved in db and displayed in history]
         			************************************************/
         $this->customerDetails = esc_sql($emailPlaintext['customer_details']);
         $this->orderDetails = esc_sql(PHP_EOL . $emailPlaintext['db_items'] . PHP_EOL . $emailPlaintext['order_summary'] . PHP_EOL);
         /***********************************************************
         				[set name and email of the the person that is ordering]
         			***********************************************************/
         $recipientName = !empty($cDetails['cname']) ? wppizza_validate_string($cDetails['cname']) : '';
         $fromEmails = !empty($cDetails['cemail']) ? wppizza_validate_email_array($cDetails['cemail']) : '';
         $this->orderClientName = wppizza_email_decode_entities($recipientName, $this->blogCharset) . '';
         $this->orderClientEmail = !empty($fromEmails[0]) ? $fromEmails[0] : '';
         /***********************************************
         				[overwrite subject vars for email subject]
         			************************************************/
         if (file_exists($this->pluginTemplateDir . '/wppizza-order-email-subject.php')) {
             /**copy to template directory to keep settings**/
             include $this->pluginTemplateDir . '/wppizza-order-email-subject.php';
         } else {
             include WPPIZZA_PATH . 'templates/wppizza-order-email-subject.php';
         }
         /**update db entry with the current time timestamp of when the order was actually send**/
         $orderDate = date('Y-m-d H:i:s', $this->currentTime);
         /**add timestamp to order_ini**/
         $oIni['time'] = $this->currentTime;
         $wpdb->query("UPDATE " . $wpdb->prefix . $this->pluginOrderTable . " SET order_date='" . $orderDate . "',order_ini='" . esc_sql(serialize($oIni)) . "' WHERE id='" . $orderid . "' ");
     }
     return;
 }
Пример #7
0
 function edd_action($action, $license, $eddName, $eddUrl)
 {
     $api_params = array('edd_action' => $action, 'license' => $license, 'item_name' => urlencode($eddName));
     // Call the custom API.
     $response = wp_remote_get(add_query_arg($api_params, $eddUrl), array('timeout' => 15, 'sslverify' => false));
     // make sure the response came back okay
     $edd['error'] = false;
     if (is_wp_error($response)) {
         $edd['error'] = true;
     } else {
         // decode the license data
         $license_data = json_decode(wp_remote_retrieve_body($response));
         $edd['status'] = wppizza_validate_string($license_data->license);
     }
     return $edd;
 }
                    } else {
                        $val = $m['validateCallback']($input['gateways'][$v['gatewayOptionsName']][$m['key']]);
                    }
                } else {
                    /*no callback defined*/
                    $val = $input['gateways'][$v['gatewayOptionsName']][$m['key']];
                }
            } else {
                $val = '';
            }
            $updateGatewayOptions[$m['key']] = $val;
        }
        /****add label and info*****/
        $lbl = wppizza_validate_string($input['gateways'][$v['gatewayOptionsName']]['gateway_label']);
        $updateGatewayOptions['gateway_label'] = !empty($lbl) ? $lbl : $v['gatewayName'];
        $updateGatewayOptions['gateway_info'] = wppizza_validate_string($input['gateways'][$v['gatewayOptionsName']]['gateway_info']);
        /****add any non-user-editable gateway specific options (version numbers for example)*****/
        if (isset($v['gatewaySettingsNonEditable']) && is_array($v['gatewaySettingsNonEditable'])) {
            foreach ($v['gatewaySettingsNonEditable'] as $neKey => $neVal) {
                $updateGatewayOptions[$neKey] = $neVal;
            }
        }
        /********update wpml******/
        $gwclass = new WPPIZZA_GATEWAYS();
        $gwclass->wppizza_gateway_register_wpml_variables($v['ident'], $v['gatewaySettings'], $updateGatewayOptions, true);
        /********update options******/
        update_option($v['gatewayOptionsName'], $updateGatewayOptions);
    }
}
/************************************************************************************************************************
*
function wppizza_surchargestoarray($str)
{
    $str = explode("|", $str);
    $array = array();
    foreach ($str as $s) {
        $keyVal = explode(":", $s);
        $key = wppizza_validate_string($keyVal[0]);
        /**this should definitely be a float/number**/
        $val = '0';
        if (isset($keyVal[1])) {
            $val = wppizza_validate_float_only($keyVal[1]);
            /**add percentage sign if required**/
            $hasPc = strpos($keyVal[1], '%');
            if ($hasPc !== false) {
                $val .= '%';
            }
        }
        $array[$key] = $val;
    }
    return $array;
}
Пример #10
0
 function wppizza_gateway_order_payment_invalid($orderid, $blogid = false, $transaction_id, $transaction_details)
 {
     global $wpdb;
     //$wpdb->hide_errors();
     $transaction_id = wppizza_validate_string($transaction_id);
     /**sanitize**/
     /**select the right blog table */
     if ($blogid && is_int($blogid) && $blogid > 1) {
         $wpdb->prefix = $wpdb->base_prefix . $blogid . '_';
     }
     $wpdb->update($wpdb->prefix . $this->pluginOrderTable, array('payment_status' => 'INVALID', 'transaction_id' => $transaction_id, 'transaction_details' => maybe_serialize($transaction_details), 'initiator' => esc_sql($this->gatewayName)), array('id' => $orderid), array('%s', '%s', '%s'), array('%d'));
 }