function andclose($PID, $order_id) { // NEED TO ADD ORDER ARCHIVE FILTER $archive = get_field('order_archive', $PID); __update_post_meta($PID, 'order_archive', $value = ''); __update_post_meta($PID, 'order_count', $value = $archive); }
function afec_check_form_func() { if (isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) { if (trim($_POST['postTitle']) === '') { $postTitleError = 'Please enter a title.'; $hasError = true; } $post_information = array('post_title' => wp_strip_all_tags($_POST['postTitle']), 'post_content' => $_POST['postContent'], 'post_type' => 'post', 'post_status' => 'pending'); $post_id = wp_insert_post($post_information); __update_post_meta($post_id, 'caccole', 'prova'); if ($post_id) { wp_redirect(home_url()); exit; } } }
function send_to_printer2($order_id, $PID = -1, $reqfrom = "woocommerce") { global $wpdb; $order = wc_get_order($order_id); if ($PID == -1 && $reqfrom == "woocommerce") { $PID = $_SESSION['sentimentPID']; } // Update Order So that it is stored in the flatterbox $currentOrders = get_field('order_count', $PID); if (strlen($currentOrders) > 0) { $currentOrders .= ','; } $currentOrders .= $order_id; __update_post_meta($PID, 'order_count', $value = $currentOrders); $orderAddOns = wc_checkout_add_ons()->get_order_add_ons($order_id); $gift = 'No'; $extracards = 0; if ($orderAddOns[2]['value'] == 1) { $gift = 'Yes'; } if ($orderAddOns[3]['value'] == 1) { $extracards = 10; } // Not needed I dont think //print_r($orderAddOns); $order_count = 1; //print_r($order); //print_r($_SESSION); do_action('woocommerce_order_details_after_customer_details', $order); $_customer = new WC_Customer($order_id); $shipping_address = $order->get_formatted_shipping_address(); $name = explode('<br/>', $shipping_address); $name = $name[0]; // echo $shipping_address; // print_r($_customer); $blankcolor = ''; $shipping_method = $order->get_shipping_method(); switch (strtoupper($shipping_method)) { case 'FEDEX EXPRESS SAVER': $shipping_method = 'FDEX_EXPRESSSAVER'; break; case 'FEDEX 2DAY': $shipping_method = 'FDEX_FEDEX2DAY'; break; case 'FEDEX PRIORITY OVERNIGHT': $shipping_method = 'FDEX_PRIORITYOVERNIGHT'; break; default: $shipping_method = 'FDXG_FEDEXGROUND'; break; } $xmlstring = '<?xml version="1.0" encoding="UTF-8"?>'; // Open Order $xmlstring .= ' <order xmlns="http://fbns/">'; if (count($order->get_items()) > 0) { foreach ($order->get_items() as $item) { // Reset Additional Count if ($orderAddOns[3]['value'] == 1) { $extracards = 10; } else { $extracards = 0; } // Add element $_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item); $qty = intval($item["pa_cardquantity"]) + $extracards; //print_r($_product); //print_r($item); //$_item = $order->get_item_meta(784); // 781 784 /* echo '------------'; echo $_item; print_r($_item); echo '------------'; */ // Start Box $xmlstring .= ' <subOrder> <orderId>' . $order_id . '-' . str_pad($order_count, 3, '0', STR_PAD_LEFT) . '</orderId> <orderDate><![CDATA[' . date('n/j/y', strtotime($order->order_date)) . ']]></orderDate> <shipTo><![CDATA[' . $name . ']]></shipTo> <shipAdd1><![CDATA[' . $_customer->get_shipping_address() . ']]></shipAdd1> <shipAdd2><![CDATA[' . $_customer->get_shipping_address_2() . ']]></shipAdd2> <shipCity><![CDATA[' . $_customer->get_shipping_city() . ']]></shipCity> <shipState><![CDATA[' . $_customer->get_shipping_state() . ']]></shipState> <shipZip><![CDATA[' . $_customer->get_shipping_postcode() . ']]></shipZip> <giftWrapped><![CDATA[' . $gift . ']]></giftWrapped>'; /* <specialInstructions><![CDATA['.htmlspecialchars_decode(stripslashes(get_field('special_instructions_to_flatterers', $PID))).']]></specialInstructions> */ $xmlstring .= ' <shipVia><![CDATA[' . $shipping_method . ']]></shipVia> <box> <shipQty>' . $item["qty"] . '</shipQty> <sku><![CDATA[' . $_product->get_sku() . '_' . $qty . ']]></sku> <font><![CDATA[Unknown]]></font> <substrate><![CDATA[Unknown]]></substrate> <boxType><![CDATA[' . $item["pa_boxtype"]; if (strlen($item["pa_boxcolor"]) > 0) { $xmlstring .= '-' . $item["pa_boxcolor"]; } $xmlstring .= ']]></boxType> <cardcolor><![CDATA[' . xmlPrepare($item["pa_cardcolor"]) . ']]></cardcolor>'; $blankcolor = xmlPrepare($item["pa_cardcolor"]); if (get_field('title_card_headline', $PID)) { $xmlstring .= ' <titlecard> <heading><![CDATA[' . xmlPrepare(get_field('title_card_headline', $PID)) . ']]></heading> <to><![CDATA[' . xmlPrepare(get_field('who_is_this_for', $PID)) . ']]></to> <from><![CDATA[' . xmlPrepare(get_field('title_card_name', $PID)) . ']]></from> </titlecard>'; } else { // For the blank parts $xmlstring .= ' <titlecard> <heading><![CDATA[]]></heading> <to><![CDATA[]]></to> <from><![CDATA[]]></from> </titlecard>'; } $sentiment_results = $wpdb->get_results("SELECT * FROM sentiments WHERE approved = 1 AND PID = " . $PID, ARRAY_A); $sentiment_count = $wpdb->num_rows; // Start Cards if ($sentiment_results) { foreach ($sentiment_results as $row) { $xmlstring .= ' <card> <note><![CDATA[' . xmlPrepare(preg_replace('/\\r/', '/R', preg_replace('/\\n(\\s*\\n)+/', '/R', preg_replace('/\\r\\n/', '/R', $row["sentiment_text"])))) . ']]></note> <author><![CDATA[' . xmlPrepare($row["sentiment_name"]) . ']]></author> <image><![CDATA[' . xmlPrepare($item["pa_cardcolor"]) . ']]></image> </card>'; } } // End Card $order_count++; // Increase Count // Extra Cards $addCards = intval($item["pa_cardquantity"]) - $sentiment_count; if ($addCards > 0) { $extracards = $extracards + $addCards; } for ($i = 0; $i < $extracards; $i++) { $xmlstring .= ' <card> <note><![CDATA[]]></note> <author><![CDATA[]]></author> <image><![CDATA[' . $blankcolor . ']]></image> </card>'; } // End Extra Cards $xmlstring .= ' </box> </subOrder>'; } // Close Box } // Close Order $xmlstring .= ' </order>'; // GET DATE $thedate = date("Ymd_Hi"); // Save File $file = $order_id . '_' . $thedate . '.xml'; //$myfile = fopen('orderlist/'.$file, "w"); //echo '<script>window.alert("HELLO -- '.$order_id.' -- '.getcwd().'");</script>'; if ($reqfrom == 'ajaxfunction') { file_put_contents('../../../orderlist/' . $file, $xmlstring); // Staging requires the ../ to be removed } else { file_put_contents('../orderlist/' . $file, $xmlstring); // Staging requires the ../ to be removed } if (false) { // removed as they are presently pulling $response = sftp_printer($file); } //echo '<script>window.alert("HELLO -- '.$order_id.' -- '.$response.'");</script>'; }
<?php require_once '../../../wp-load.php'; global $wpdb; $action = $_POST["action"]; $PID = $_POST["PID"]; if ($action == "delete") { __update_post_meta($PID, 'title_card_headline', $value = ''); __update_post_meta($PID, 'title_card_name', $value = ''); echo "ok"; }
global $current_user; get_currentuserinfo(); //$current_userID = $current_user->ID, // I could also use $user_ID, right? $current_userID = get_current_user_id(); $args = array('author' => $current_userID, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'flatterboxes', 'posts_per_page' => -1); // get his posts 'ASC' $current_user_posts = get_posts($args); $i = 1; foreach ($current_user_posts as $post) { setup_postdata($post); // Check for URL variable -- Can be removed once legacy items are covered if (strlen(get_field('unique_url')) == 0) { //$current_user = wp_get_current_user(); //$uniquestart = $current_user->user_email.get_the_ID(); //__update_post_meta( get_the_ID(), 'unique_url', $value = md5(uniqid($uniquestart, true))); __update_post_meta(get_the_ID(), 'unique_url', $value = getURLToken(10)); } ?> <div class="event anchor-<?php the_id(); ?> " id="flatterbox-<?php echo $i; ?> "> <div class="detail"> <div class="img-holder"> <?php foreach (get_the_terms(get_the_ID(), 'flatterbox_type') as $cat) { $catimage = z_taxonomy_image_url($cat->term_id);
the_field('page_title'); ?> </h1> </div> <div class="box"> <div class="box-padding"> <?php if ($_POST['approved'] == 1) { echo '<h2>Reminders Sent</h2>'; the_content(); // Special Instructions __update_post_meta($PID, 'special_instructions_to_flatterers', $value = $_POST['special-instructions']); // Reminder if (false) { // Hiding, but keeping incase we want to add it back in 7/14/2015 __update_post_meta($PID, 'reminder_instructions', $value = $_POST['additional-reminder']); } processFlattererReminder(0, $PID, $_POST['flatterers'], false); // Change to true to re-enable reminder portion (also in includes/emailFunctions.php) $hideSubmit = true; } else { ?> <h2>Reminder to Send</h2> <div id="flattererfield-single"> <?php $flatterer_results = $wpdb->get_results("SELECT * FROM flatterers WHERE flatterer_email <> '' AND PID = " . $PID, ARRAY_A); $rowCount = $wpdb->num_rows; $nCount = 0; $hideSubmit = false; ?> <?php
<?php /* Template Name: FB Step 6 Sentiment */ // Save Title Card if ($_POST['submittitlecard']) { $newpid = $_POST['sentimentPID']; __update_post_meta($newpid, 'title_card_headline', $value = $_POST['sentimenttext']); __update_post_meta($newpid, 'title_card_name', $value = $_POST['titlenamefamily']); if (isset($_GET['redirect'])) { wp_redirect(home_url() . '/my-flatterbox/'); exit; } } get_header('steps'); //If this is the first time the box is being configured, get the initial flatterer list and insert into DB. if ($_GET["initialinvite"]) { global $wpdb; for ($i = 0; $i < count($_SESSION['flattereremails']); $i++) { if ($_SESSION['flattereremails'][$i] != "") { $wpdb->insert('flatterers', array('PID' => $_SESSION["new_flatterbox_id"], 'flatterer_email' => $_SESSION["flattereremails"][$i], 'flatterer_name' => $_SESSION["flatterernames"][$i], 'responded' => 0), array('%d', '%s', '%s', '%d')); $flatterer_id = $wpdb->insert_id; // check if flatterbox is private and assign a passcode if so. $flatterbox_post = get_post($_SESSION["new_flatterbox_id"]); $PID = $flatterbox_post->ID; $private = get_field("private", $PID); // For Passcode $can_invite = get_field("can_invite", $PID); // For Flatterer able to Invite if ($private) { $passcode = getRandomCode(); $wpdb->update('flatterers', array('passcode' => $passcode), array('FID' => $flatterer_id), array('%s'), array('%d'));
$upgradecost = -1; // Handling the overages } } } //Setting the counts if ($upgradeamount >= 0) { $the_final_count = strtoupper($upgradeamount); } // Updating the DB if ($upgradedb > 0) { __update_post_meta(get_the_ID(), 'card_quantity', $value = $upgradedb); __update_post_meta(get_the_ID(), 'total_price', $value = intval($basecost)); } if ($auto10 == 1) { __update_post_meta(get_the_ID(), 'add10', $value = 1); } } ?> <?php if (false) { // Old layout for counter ?> <em class="counter"><?php echo $received_count; ?> /<?php echo $cardamount; ?> </em><?php }
function set_post_content_34($entry, $form) { // Create flatterbox post object //Get the current user info to insert into flatterbox information $current_user = wp_get_current_user(); $current_user_name = $current_user->user_login; //Set up the flatterbox information to insert $my_flatterbox = array('post_title' => $entry["1"] . '\'s ' . $entry["26"] . ' Flatterbox', 'post_type' => 'flatterboxes', 'post_content' => '', 'post_status' => 'publish', 'post_author' => get_current_user_id()); // Insert the post into the database if (!isset($_SESSION["new_flatterbox_id"])) { $new_post_id = wp_insert_post($my_flatterbox); $newpid = $new_post_id; } else { $newpid = $_SESSION["new_flatterbox_id"]; } $_SESSION["occassion_name"] = $entry["26"]; wp_set_object_terms($new_post_id, $entry["26"], 'flatterbox_type', 0); //Convert date to ACF's format $date = new DateTime($entry["2"]); $newdate = $date->Format(Ymd); $boxtheme = ''; switch ($entry["26"]) { case 'Birthday': $boxtheme = $entry["27"]; break; case 'Anniversary': $boxtheme = $entry["28"]; break; case 'Military Gift': $boxtheme = $entry["53"]; break; case 'Get Well': $boxtheme = $entry["52"]; break; case 'Bar Mizvah': $boxtheme = $entry["51"]; break; case 'New Baby/Parents': $boxtheme = $entry["50"]; break; case 'Engagement': $boxtheme = $entry["49"]; break; case 'Wedding': $boxtheme = $entry["48"]; break; case 'Graduation': $boxtheme = $entry["47"]; break; case 'Bridal Shower': $boxtheme = $entry["46"]; break; case "Boss' Gift": $boxtheme = $entry["45"]; break; case 'Holiday': $boxtheme = $entry["44"]; break; case "Valentine's Day": $boxtheme = $entry["43"]; break; case "Father's Day": $boxtheme = $entry["42"]; break; case 'Sweet 16': $boxtheme = $entry["41"]; break; case 'Love You Because...': $boxtheme = $entry["40"]; break; case 'Retirement': $boxtheme = $entry["39"]; break; case 'Hanukkah': $boxtheme = $entry["38"]; break; case "Mother's Day": $boxtheme = $entry["37"]; break; case 'Funeral': $boxtheme = $entry["36"]; break; case 'New Year Encouragement': $boxtheme = $entry["35"]; break; case 'Just Because...': $boxtheme = $entry["34"]; break; case 'Divorce Encouragement': $boxtheme = $entry["33"]; break; case 'Corporate Meeting': $boxtheme = $entry["32"]; break; case "Teacher's Gift": $boxtheme = $entry["31"]; break; case 'Christmas': $boxtheme = $entry["30"]; break; case "Coach's Gift": $boxtheme = $entry["29"]; break; } __update_post_meta($newpid, 'occasion', $value = $entry["26"]); $_SESSION["occasion"] = $entry["26"]; __update_post_meta($newpid, 'box_theme', $value = $boxtheme); $_SESSION["box_theme"] = $boxtheme; __update_post_meta($newpid, 'who_is_this_for', $value = $entry["1"]); $_SESSION["who_is_this_for"] = $entry["1"]; __update_post_meta($newpid, 'who_is_this_from', $value = $entry["65"]); $_SESSION["who_is_this_from"] = $entry["65"]; __update_post_meta($newpid, 'date_of_birthday', $value = $newdate); $_SESSION["date_of_birthday"] = $newdate; __update_post_meta($newpid, 'birthday_occassion', $value = $entry["3"]); $_SESSION["birthday_occassion"] = $entry["3"]; __update_post_meta($newpid, 'card_style', $value = $_SESSION["cardcolor"]); __update_post_meta($newpid, 'card_quantity', $value = $_SESSION["cardquantity"]); __update_post_meta($newpid, 'box_style', $value = $_SESSION["boxtype"]); __update_post_meta($newpid, 'introductory_card_message', $value = $entry["4"]); $_SESSION["introductory_card_message"] = $entry["4"]; __update_post_meta($newpid, 'special_instructions_to_flatterers', $value = $entry["5"]); $_SESSION["special_instructions_to_flatterers"] = $entry["5"]; __update_post_meta($newpid, 'private', $value = $entry["8"]); // Used for Passcode $_SESSION["private"] = $entry["8"]; __update_post_meta($newpid, 'can_invite', $value = $entry["69"]); // Used for Flaterers to be able to Invite $_SESSION["can_invite"] = $entry["69"]; __update_post_meta($newpid, 'allow_to_see_eachother', $value = $entry["25"]); $_SESSION["allow_to_see_eachother"] = $entry["25"]; __update_post_meta($newpid, 'allow_to_share', $value = $entry["7"]); $_SESSION["allow_to_share"] = $entry["7"]; __update_post_meta($newpid, 'allow_profanity', $value = $entry["9"]); $_SESSION["allow_profanity"] = $entry["9"]; __update_post_meta($newpid, 'notification_frequency', $value = $entry["10"]); $_SESSION["notification_frequency"] = $entry["10"]; __update_post_meta($newpid, 'total_price', $value = $_SESSION["totalprice"]); __update_post_meta($newpid, 'box_image_url', $value = $_SESSION["boxtypeimg"]); //$_SESSION["boxtypeimg"] __update_post_meta($newpid, 'box_color', $value = $_SESSION["boxcolor"]); // Dates for Deadlines __update_post_meta($newpid, 'date_of_delivery', $value = $newdate); __update_post_meta($newpid, 'date_of_project_complete', $value = $newdate); __update_post_meta($newpid, 'date_sentiments_complete', $value = $newdate); // Dates for Deadlines //Convert dates to ACF's format $date = new DateTime($entry["2"]); $delivery = $date->Format(Ymd); $date = new DateTime($entry["19"]); $project = $date->Format(Ymd); $date = new DateTime($entry["54"]); $sentiment = $date->Format(Ymd); __update_post_meta($newpid, 'date_of_delivery', $value = $delivery); $_SESSION["date_of_delivery"] = $delivery; __update_post_meta($newpid, 'date_of_project_complete', $value = $project); $_SESSION["date_of_project_complete"] = $project; __update_post_meta($newpid, 'date_sentiments_complete', $value = $sentiment); $_SESSION["date_sentiments_complete"] = $sentiment; $_SESSION["new_flatterbox_id"] = $newpid; }