public function metabox_orderID() { $orderID = intval($_POST['orderID']); $wpwsO = WPWS_Model::getDataOrderID($orderID); //Type $term_id_type = $wpwsO->term_id_type; $wpws_type = WPWS_Model::getTermByTermID($term_id_type); //Length $term_id_length = $wpwsO->term_id_length; $wpws_length = WPWS_Model::getTermByTermID($term_id_length); //Category $categoryO = get_term($wpwsO->term_id_category, 'category'); $wpws_category = $categoryO->name; //Quantity $wpws_quantity = $wpwsO->quantity; //Notes $wpws_notes = stripslashes_deep(nl2br($wpwsO->notes)); ?> <ul style="list-style-type:none; margin:0; padding:0;"> <li><strong><em>Type: </em></strong><?php echo $wpws_type; ?> </li> <li> <strong><em>Length: </em></strong><?php echo $wpws_length; ?> </li> <li><strong><em>Category: </em></strong><?php echo $wpws_category; ?> </li> <li><strong><em>Quantity: </em></strong><?php echo $wpws_quantity; ?> </li> <li><strong><em>Notes: </em></strong><?php echo $wpws_notes; ?> </li> </ul> <?php die; }
public function wpws_meta_box_orderID($post) { global $current_user; $wpws_meta_orderID = get_post_meta($post->ID, 'wpws_meta_orderID', true); $taskA = WPWS_Model::getOrders(); //Get the Order IDs foreach ($taskA as $orderA) { $orderIDA[] = $orderA->orderID; } ?> <select name="wpws_meta_orderID" id="wpws_meta_orderID" size="4" style="height:90px;"> <?php foreach ($orderIDA as $orderID) { ?> <option value="<?php echo $orderID; ?> " <?php selected($wpws_meta_orderID, $orderID); ?> >Order ID: <?php echo $orderID; ?> </option> <?php } ?> </select> <p id="orderInfo"></p> <?php }
public function wpws_submit_form_display() { $payemail = get_option('wpws_settings_payemail'); $wpws_settings_pages = get_option('wpws_settings_pages'); $productPage = $wpws_settings_pages['wpws_product_page']; $payURL = get_page_link($productPage); //retrieve product ID, if exists if (isset($_GET['productID'])) { $productID = intval($_GET['productID']); //Retrieve term IDs based on product ID $terms = $this->wpws_model->getTermsByProductID($productID); $_POST['term_id_type'] = $terms['term_id_type']; $_POST['term_id_length'] = $terms['term_id_length']; } else { //if no product ID is set, then use the one set in the Settings menu $productID = get_option('wpws_default_product'); //Retrieve term IDs based on product ID $terms = $this->wpws_model->getTermsByProductID($productID); $_POST['term_id_type'] = $terms['term_id_type']; $_POST['term_id_length'] = $terms['term_id_length']; } $term_id_type = !empty($_POST['term_id_type']) ? intval($_POST['term_id_type']) : 0; $term_id_length = !empty($_POST['term_id_length']) ? intval($_POST['term_id_length']) : 0; $term_id_category = !empty($_POST['term_id_category']) ? intval($_POST['term_id_category']) : 0; //from actual wp_terms table $wpws_quantity = !empty($_POST['wpws_quantity']) ? intval($_POST['wpws_quantity']) : 0; $wpws_notes = !empty($_POST['wpws_notes']) ? $_POST['wpws_notes'] : NULL; //Login $user_login = !empty($_POST['user_login']) ? $_POST['user_login'] : NULL; ?> <!-- Display confirmation message to users who submit a book review --> <?php if (isset($_GET['orderID']) && isset($_SERVER['HTTP_REFERER'])) { $orderID = intval($_GET['orderID']); //Get object data of Order ID $orderData = WPWS_Model::getDataOrderID($orderID); //retrieve the product Type/Length name $item_type = WPWS_Model::getTermByTermID($orderData->term_id_type); $item_type = !empty($item_type) ? $item_type : NULL; $item_length = WPWS_Model::getTermByTermID($orderData->term_id_length); $item_length = !empty($item_length) ? $item_length : NULL; $item_name = $item_type && $item_length ? $item_type . '/' . $item_length : $item_type; ?> <div style="background:#0C6;"> Thank you for your request - please complete payment to continue. <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<?php echo $payemail; ?> "> <input type="hidden" name="item_name" value="<?php echo $item_name; ?> "> <input type="hidden" name="item_number" value="<?php echo $orderData->productID; ?> "> <input type="hidden" name="quantity" value="<?php echo $orderData->quantity; ?> "> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="amount" value="<?php echo number_format($orderData->price, 2); ?> "> <input type="hidden" name="return" value="<?php echo $payURL; ?> "> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> </div> <?php exit; } ?> <form method="post" id="submit-article" action=""> <!-- Nonce fields to verify form submission --> <?php wp_nonce_field('articlesubmit_form', 'wpws_submit_form'); ?> <!-- Post variable to indicate user submitted --> <input type="hidden" name="wpws_article_submit" value="1" /> <!-- Hidden variable for ProductID --> <input type="hidden" name="productID" value="<?php echo $productID; ?> " /> <table> <tr> <td>Type</td> <td> <?php // Retrieve array of all types in system //$types = get_terms( 'wpws_article_type', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); $taxonomy_id = $this->wpws_model->getTaxonomyID('Type'); $types = $this->wpws_model->getTerms($taxonomy_id); // Check if types were found if (!is_wp_error($types) && !empty($types)) { echo '<select name="term_id_type">'; echo '<option value="">---</option>'; // Display all types foreach ($types as $type) { ?> <option value="<?php echo $type->term_id; ?> " <?php echo selected($term_id_type, $type->term_id); ?> ><?php echo $type->term; ?> </option> <?php } echo '</select>'; } ?> </td> </tr> <tr> <td>Length</td> <td> <?php // Retrieve array of all book types in system //$lengths = get_terms( 'wpws_article_length', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); $taxonomy_id = $this->wpws_model->getTaxonomyID('Length'); $lengths = $this->wpws_model->getTerms($taxonomy_id); // Check if types were found if (!is_wp_error($lengths) && !empty($lengths)) { echo '<select name="term_id_length">'; echo '<option value="">---</option>'; // Display all types foreach ($lengths as $length) { ?> <option value="<?php echo $length->term_id; ?> " <?php echo selected($term_id_length, $length->term_id); ?> ><?php echo $length->term; ?> </option> <?php } echo '</select>'; } ?> </td> </tr> <tr> <td>Category</td> <td> <?php $mycategories = get_option('wpws_categories'); if (!empty($mycategories)) { $mycategories = implode(",", $mycategories); } else { $mycategories = ''; } $args = array('type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'id', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => $mycategories, 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false); $categories = get_categories($args); // Check if types were found if (!is_wp_error($categories) && !empty($categories)) { echo '<select name="term_id_category">'; echo '<option value="">- Select -</option>'; // Display all types foreach ($categories as $category) { ?> <option value="<?php echo $category->term_id; ?> " <?php echo selected($term_id_category, $category->term_id); ?> ><?php echo $category->name; ?> </option> <?php } echo '</select>'; } ?> </td> </tr> <tr> <td>Quantity</td> <td> <input type="text" name="wpws_quantity" size="3" value="<?php echo $wpws_quantity; ?> " /> </td> </tr> <tr> <td>Notes</td> <td><textarea name="wpws_notes"><?php echo $wpws_notes; ?> </textarea></td> </tr> <?php if (!$this->is_login) { ?> <tr> <td colspan="3">Please Login/Register.</td> </tr> </tr> <tr> <td>Email:</td> <td> <input type="text" name="user_login" size="25" value="<?php echo $user_login; ?> " /> </td> </tr> </tr> <tr> <td>Password:</td> <td> <input type="password" name="user_password" size="25" value="" /> </td> </tr> <?php } ?> </table> <input type="submit" name="submit" value="Submit" /> </form> <?php }