Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a file called post.php and test.txt that is writable by the web server, upload those files to a location such as yourdomain.com/post.php and use this URL as your Post URL in your Universal Module Product configuration.

Code Block
languagephp
<?php
// Check if the request method is POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Get the POST data
    $postData = file_get_contents('php://input');

    // Parse the URL-encoded data into an associative array
    parse_str($postData, $dataArray);

    // Specify the file name
    $fileName = 'test.txt';

    // Convert the array to a readable string format
    $formattedData = print_r($dataArray, true);

    // Attempt to write the formatted data to the file
    if (file_put_contents($fileName, $formattedData) !== false) {
        // Send a success response
        http_response_code(200);
        echo "Data successfully written to $fileName.";
    } else {
        // Send an error response if unable to write
        http_response_code(500);
        echo "Failed to write data to $fileName.";
    }
} else {
    // Send a method not allowed response if the request is not POST
    http_response_code(405);
    echo "Method not allowed. Please use a POST request.";
}
?>

Set the URL for the notice to the location of post.php and perform the action. Then check the test.txt file for the results. You should see something like this in the file:


Expand
titleClick here to expand and see sample data...

Array
(
    [_package] => Array
        (
            [id] => 4
            [id_format] => {num}
            [id_value] => 4
            [id_code] => 4
            [module_id] => 4
            [name] => Package Test
            [module_row] => 2
            [module_group_client] => 0
            [taxable] => 0
            [single_term] => 0
            [status] => active
            [hidden] => 0
            [company_id] => 1
            [upgrades_use_renewal] => 1
            [manual_activation] => 0
            [override_price] => 0
            [email_content] => Array
                (
                    [0] => Array
                        (
                            [lang] => de_de
                            [html] =>
                            [text] =>
                        )

                    [1] => Array
                        (
                            [lang] => en_us
                            [html] =>
                            [text] =>
                        )

                )

            [pricing] => Array
                (
                    [0] => Array
                        (
                            [id] => 4
                            [pricing_id] => 34
                            [package_id] => 4
                            [term] => 1
                            [period] => month
                            [price] => 5.0000
                            [price_renews] => 5.0000
                            [setup_fee] => 0.0000
                            [cancel_fee] => 0.0000
                            [currency] => USD
                            [precision] => 2
                            [in_use] => 1
                            [default] => 0
                        )

                )

            [groups] => Array
                (
                    [0] => Array
                        (
                            [id] => 4
                            [type] => standard
                            [company_id] => 1
                            [allow_upgrades] => 1
                            [names] => Array
                                (
                                    [0] => Array
                                        (
                                            [lang] => de_de
                                            [name] => Test
                                        )

                                    [1] => Array
                                        (
                                            [lang] => en_us
                                            [name] => Test
                                        )

                                )

                            [name] => Test
                        )

                )

            [names] => Array
                (
                    [0] => Array
                        (
                            [lang] => de_de
                            [name] => Package Test
                        )

                    [1] => Array
                        (
                            [lang] => en_us
                            [name] => Package Test
                        )

                )

            [descriptions] => Array
                (
                    [0] => Array
                        (
                            [lang] => de_de
                            [html] =>
                            [text] =>
                        )

                    [1] => Array
                        (
                            [lang] => en_us
                            [html] =>
                            [text] =>
                        )

                )

            [description] =>
            [description_html] =>
        )

    [_action] => service_notice_add
    [_other] => Array
        (
            [pricing_id] => 4
            [status] => active
            [use_module] => true
            [module_row_id] => 2
            [save] => Continue
            [package_group_id] => 4
            [qty] => 1
            [client_id] => 2
            [staff_id] => 1
            [coupon_packages] => Array
                (
                    [4] => 4
                )

            [date_added] => 2024-08-02 19:13:13
            [date_renews] => 2024-09-02 19:13:13
        )

)