示例#1
0
 private function addProductwithPlexOrder($plexOrderId, $orderObject, $Part_No, $Price, $Quantity)
 {
     try {
         $plexServiceRequestObject = new plexServiceRequest();
         $responseHandlerObject = new ResponseHandler();
         $plexuserUserId = 'PWPU' . str_pad($orderObject->get_user_id(), 6, '0', STR_PAD_LEFT);
         /*request parameter*/
         $paramArray = array(array('Name' => 'Customer_Code', 'Value' => $plexuserUserId, 'Required' => 'false', 'Output' => 'false'), array('Name' => 'Order_No', 'Value' => $plexOrderId, 'Required' => 'false', 'Output' => 'false'), array('Name' => 'Part_No', 'Value' => $Part_No, 'Required' => 'false', 'Output' => 'false'), array('Name' => 'Price', 'Value' => $Price, 'Required' => 'false', 'Output' => 'false'), array('Name' => 'Quantity', 'Value' => $Quantity, 'Required' => 'false', 'Output' => 'false'));
         /* adding product to plex order*/
         $rawResponse = $plexServiceRequestObject->call('ExecuteDataSource', PLEX_WRITE_NEW_ORDER_LINE, $paramArray);
         // echo '<pre>';
         // print_r($rawResponse);
         // echo '</pre>';
         return $rawResponse->ExecuteDataSourceResult->Message;
     } catch (Exception $exec) {
         PlexLog::addLog(' Error =>(' . $customerId . ') Exception occure while addProductwithPlexOrder. Message :' . $exec->getMessage());
         return '';
     }
 }
示例#2
0
function putPlexProductDataIntoWoocommerceProduct($woocommerceProductName, $plexProductData)
{
    if (0 == count($plexProductData)) {
        /* no data found */
        return;
    }
    try {
        global $wpdb;
        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_name = '" . $woocommerceProductName . "'");
        if (!$post_id) {
            $woocommerceProductObj = get_page_by_title($woocommerceProductName, OBJECT, 'product');
            $post_id = $woocommerceProductObj->ID;
        }
        update_post_meta($post_id, 'plexPartKey', $plexProductData['Part_Key']);
        update_post_meta($post_id, 'plexPartNo', $plexProductData['Part_No']);
        update_post_meta($post_id, 'plexRevision', $plexProductData['Revision']);
        update_post_meta($post_id, 'plexPartName', $plexProductData['Part_Name']);
        update_post_meta($post_id, 'plexAttachmentHist', $plexProductData['Attachment_List']);
        update_post_meta($post_id, '_regular_price', $plexProductData['Price']);
        update_post_meta($post_id, 'plexPartStatus', $plexProductData['Part_Status']);
        update_post_meta($post_id, 'plexPartType', $plexProductData['Part_Type']);
        update_post_meta($post_id, 'plexCustomerPartNo', $plexProductData['Customer_Part_No']);
        update_post_meta($post_id, 'plexCustomerPartPrice', $plexProductData['Customer_Part_Price']);
        update_post_meta($post_id, 'plexImageName', $plexProductData['Image_Name']);
        if ($plexProductData['FG_Quantity']) {
            update_post_meta($post_id, '_manage_stock', 'yes');
            update_post_meta($post_id, '_stock_status', 'instock');
        } else {
            update_post_meta($post_id, '_stock_status', 'outofstock');
        }
        update_post_meta($post_id, '_stock', $plexProductData['FG_Quantity']);
    } catch (Exception $exec) {
        PlexLog::addLog(' Error =>() Exception occure while putting product information in woo commerce . Message :' . $exec->getMessage());
        return false;
    }
}
示例#3
0
 public function isShippingAddressPresent($customerId)
 {
     try {
         $response = $this->getShippingAddress($customerId);
         if (count($response)) {
             return true;
         } else {
             return false;
         }
     } catch (Exception $exec) {
         PlexLog::addLog(' Error =>(' . $customerId . ') Exception occure while checkimg if shipping address exists. Message :' . $exec->getMessage());
         return false;
     }
 }
function plex_order_status_update_callback_function($customer_orders)
{
    if (!$customer_orders) {
        return false;
    }
    PlexLog::addLog(' Info =>going to update order status for user ' . get_current_user_id());
    if (!is_array($customer_orders)) {
        $customer_orders = array($customer_orders);
    }
    foreach ($customer_orders as $key => $woo_order) {
        $WC_OrderObj = new WC_Order($woo_order->ID);
        PlexLog::addLog(' Info =>going to update order status for orderid ' . $WC_OrderObj->id);
        if (!('COMPLETED' == strtoupper($WC_OrderObj->get_status()) || 'CANCELLED' == strtoupper($WC_OrderObj->get_status()))) {
            $plexOrderId = get_post_meta($WC_OrderObj->id, 'plexOrderId', true);
            if ('' != $plexOrderId) {
                $orderStatus = getOrderStatusFromPlex($plexOrderId);
                PlexLog::addLog(' Info =>orderStatus for plex order id=' . $plexOrderId . ' is = ' . $orderStatus);
                switch ($orderStatus) {
                    case 'Closed':
                        $WC_OrderObj->update_status('Completed');
                        update_post_meta($WC_OrderObj->id, 'plexOrderId', $plexOrderId);
                        break;
                    case 'Awaiting Approval':
                    case 'Open':
                    case 'Direct Open':
                        $WC_OrderObj->update_status('processing');
                        update_post_meta($WC_OrderObj->id, 'plexOrderId', $plexOrderId);
                        break;
                    case 'Cancelled':
                        $WC_OrderObj->update_status('Cancelled');
                        update_post_meta($WC_OrderObj->id, 'plexOrderId', $plexOrderId);
                        break;
                    case 'Consumer Service Hold':
                    case 'Order Entry Hold':
                    case 'Price Approval Hold':
                    case 'Credit Hold':
                    case 'Credit Card Hold':
                    case 'Hold':
                        $WC_OrderObj->update_status('on-hold');
                        update_post_meta($WC_OrderObj->id, 'plexOrderId', $plexOrderId);
                        break;
                    default:
                        PlexLog::addLog(' Info =>order status unavailable');
                        $WC_OrderObj->update_status('Cancelled');
                        update_post_meta($WC_OrderObj->id, 'plexOrderId', $plexOrderId);
                }
            } else {
                PlexLog::addLog(' Info =>plexOrderId not found');
            }
        } else {
            PlexLog::addLog(' Info =>order status in not processing; it is :' . $WC_OrderObj->get_status());
        }
    }
}