예제 #1
0
 public static function add_list_table()
 {
     // echo "Donation Table";
     $newwp_list_table = new FP_List_Table_RAC();
     $newwp_list_table->prepare_items();
     $newwp_list_table->display();
 }
예제 #2
0
function fp_rac_extract_cart_details($each_cart)
{
    ob_start();
    ?>

    <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
        <thead>
            <?php 
    if (get_option('rac_hide_product_name_product_info_shortcode') != 'yes') {
        ?>

            <th class="td" scope="col" style="text-align:left;">
                <?php 
        echo fp_get_wpml_text('rac_template_product_name', $each_cart->wpml_lang, get_option('rac_product_info_product_name'));
        ?>

            </th>
        <?php 
    }
    if (get_option('rac_hide_product_image_product_info_shortcode') != 'yes') {
        ?>

            <th class="td" scope="col" style="text-align:left;">
                <?php 
        echo fp_get_wpml_text('rac_template_product_image', $each_cart->wpml_lang, get_option('rac_product_info_product_image'));
        ?>

            </th>
        <?php 
    }
    if (get_option('rac_hide_product_quantity_product_info_shortcode') != 'yes') {
        ?>

            <th class="td" scope="col" style="text-align:left;">
                <!-- For Quantity -->
                <?php 
        echo fp_get_wpml_text('rac_template_product_quantity', $each_cart->wpml_lang, get_option('rac_product_info_quantity'));
        ?>

            </th>
        <?php 
    }
    if (get_option('rac_hide_product_price_product_info_shortcode') != 'yes') {
        ?>

            <th class="td" scope="col" style="text-align:left;">
                <?php 
        echo fp_get_wpml_text('rac_template_product_price', $each_cart->wpml_lang, get_option('rac_product_info_product_price'));
        ?>

            </th>
        <?php 
    }
    ?>

    </thead>
    <tbody>
        <?php 
    $subtotal = '';
    $tax = '';
    $cart_array = maybe_unserialize($each_cart->cart_details);
    if (is_array($cart_array) && !empty($cart_array)) {
        if (isset($cart_array[0]['cart'])) {
            foreach ($cart_array[0]['cart'] as $eachproduct) {
                $product_name = get_the_title($eachproduct['product_id']);
                if (isset($eachproduct['variation']) && !empty($eachproduct['variation'])) {
                    $product_name = $product_name . fp_rac_get_formatted_variation($eachproduct['variation']);
                }
                $image = get_the_post_thumbnail($eachproduct['product_id'], array(90, 90));
                $quantity = $eachproduct['quantity'];
                $price = $eachproduct['line_subtotal'];
                $subtotal += $eachproduct['line_subtotal'];
                $tax += $eachproduct['line_subtotal_tax'];
                echo fp_split_rac_items_in_cart($product_name, $image, $quantity, FP_List_Table_RAC::format_price($price));
            }
        } elseif (is_array($cart_array) && !empty($cart_array)) {
            if (isset($cart_array['visitor_mail'])) {
                unset($cart_array['visitor_mail']);
            }
            if (isset($cart_array['first_name'])) {
                unset($cart_array['first_name']);
            }
            if (isset($cart_array['last_name'])) {
                unset($cart_array['last_name']);
            }
            if (isset($cart_array['visitor_phone'])) {
                unset($cart_array['visitor_phone']);
            }
            foreach ($cart_array as $myproducts) {
                $product_name = get_the_title($myproducts['product_id']);
                if (isset($myproducts['variation']) && !empty($myproducts['variation'])) {
                    $product_name = $product_name . fp_rac_get_formatted_variation($myproducts['variation']);
                }
                $image = get_the_post_thumbnail($myproducts['product_id'], array(90, 90));
                $quantity = $myproducts['quantity'];
                $price = $myproducts['line_subtotal'];
                $subtotal += $myproducts['line_subtotal'];
                $tax += $myproducts['line_subtotal_tax'];
                echo fp_split_rac_items_in_cart($product_name, $image, $quantity, FP_List_Table_RAC::format_price($price));
            }
        }
    } elseif (is_object($cart_array)) {
        $order = new WC_Order($cart_array->id);
        foreach ($order->get_items() as $products) {
            $product_name = get_the_title($products['product_id']);
            $image = get_the_post_thumbnail($products['product_id'], array(90, 90));
            $quantity = $products['qty'];
            $price = $products['line_subtotal'];
            $subtotal += $products['line_subtotal'];
            $tax += $products['line_subtotal_tax'];
            echo fp_split_rac_items_in_cart($product_name, $image, $quantity, FP_List_Table_RAC::format_price($price));
        }
    }
    ?>

    </tbody>
    <?php 
    if (get_option('rac_hide_tax_total_product_info_shortcode') != 'yes') {
        ?>

    <tfoot>
        <tr>
            <?php 
        $i = 1;
        ?>

            <th class="td" scope="row" colspan="3" style="text-align:left; <?php 
        if ($i == 1) {
            echo 'border-top-width: 4px;';
        }
        ?>
"><?php 
        echo fp_get_wpml_text('rac_template_subtotal', $each_cart->wpml_lang, get_option('rac_product_info_subtotal'));
        ?>
</th>
            <td class="td" style="text-align:left; <?php 
        if ($i == 1) {
            echo 'border-top-width: 4px;';
        }
        ?>
"><?php 
        echo FP_List_Table_RAC::format_price($subtotal);
        ?>
</td>
        </tr>
        <?php 
        if ($tax > 0) {
            ?>

        <tr>
            <?php 
            $i = 1;
            //            foreach ( WC()->cart->get_tax_totals() as $code => $tax1 ){
            //                $label = $tax1->label;
            //            }
            ?>

            <th class="td" scope="row" colspan="3" style="text-align:left; <?php 
            if ($i == 1) {
                echo 'border-top-width: 4px;';
            }
            ?>
"><?php 
            echo fp_get_wpml_text('rac_template_tax', $each_cart->wpml_lang, get_option('rac_product_info_tax'));
            ?>
</th>
            <td class="td" style="text-align:left; <?php 
            if ($i == 1) {
                echo 'border-top-width: 4px;';
            }
            ?>
"><?php 
            echo FP_List_Table_RAC::format_price($tax);
            ?>
</td>
        </tr>
        <?php 
        }
        ?>

        <tr>
            <?php 
        $i = 1;
        ?>

            <th class="td" scope="row" colspan="3" style="text-align:left; <?php 
        if ($i == 1) {
            echo 'border-top-width: 4px;';
        }
        ?>
"><?php 
        echo fp_get_wpml_text('rac_template_total', $each_cart->wpml_lang, get_option('rac_product_info_total'));
        ?>
</th>
            <td class="td" style="text-align:left; <?php 
        if ($i == 1) {
            echo 'border-top-width: 4px;';
        }
        ?>
"><?php 
        echo FP_List_Table_RAC::format_price($subtotal + $tax);
        ?>
</td>
        </tr>
        
    </tfoot>
    <?php 
    }
    ?>

    </table>
    <?php 
    return ob_get_clean();
}
    public static function fp_rac_reports()
    {
        if (isset($_POST['rac_clear_reports'])) {
            delete_option('rac_abandoned_count');
            delete_option('rac_mail_count');
            delete_option('rac_link_count');
            delete_option('rac_recovered_count');
            delete_option('fp_rac_recovered_order_ids');
        }
        ?>

        <table class="rac_reports form-table">
            <tr>
                <th>
                    Number of Abandoned Carts Captured
                </th>
                <td>
                    <?php 
        if (get_option('rac_abandoned_count')) {
            echo get_option('rac_abandoned_count');
        } else {
            // if it is boolean false then there is no value. so give 0
            echo "0";
        }
        ?>

                </td>
            </tr>
            <tr>
                <th>
                    Number of total Emails Sent
                </th>
                <td>
                    <?php 
        if (get_option('rac_mail_count')) {
            echo get_option('rac_mail_count');
        } else {
            echo "0";
        }
        ?>

                </td>
            </tr>
            <tr>
                <th>
                    Number of total Email links clicked
                </th>
                <td>
                    <?php 
        if (get_option('rac_link_count')) {
            echo get_option('rac_link_count');
        } else {
            echo "0";
        }
        ?>

                </td>
            </tr>
            <tr>
                <th>
                    <?php 
        _e('Number of Carts Recovered', 'recoverabandoncart');
        ?>

                </th>
                <td>
                    <?php 
        if (get_option('rac_recovered_count')) {
            echo get_option('rac_recovered_count');
        } else {
            echo "0";
        }
        ?>

                </td>
            </tr>
            <tr>
                <th>
                    <?php 
        _e('Total Sales Amount Recovered', 'recoverabandoncart');
        ?>

                </th>
                <td>
                    <?php 
        $get_order_ids = array_filter((array) get_option('fp_rac_recovered_order_ids'));
        $total_sum = array();
        if (!empty($get_order_ids)) {
            foreach ($get_order_ids as $key => $value) {
                $total_sum[] = $value['order_total'];
            }
        }
        $total_sum = array_sum($total_sum);
        //var_dump($total_sum);
        echo FP_List_Table_RAC::format_price($total_sum);
        ?>

                </td>
            </tr>
        </table>
        <br>
        <input type="submit" name="rac_clear_reports" id="rac_clear_reports" class="rac_clear_reports button-primary" value="Clear Reports" onclick="return confirm('Are you sure to clear the reports ?')">
        <style type="text/css">.rac_reports {
                width:50%;
                background-color:white;
                border:2px solid #21759b;
                border-collapse:unset;
                border-top: 4px solid #21759b;
                margin-top: 20px !important;

            }
            .rac_reports th{
                padding: 20px;
            }
        </style>
        <?php 
    }