download product price

Posted by: carlo fattori

22nd June 2022, 9:32 am

carlo fattori

@carlo_fattori

22 Jun 2022
9:32 am

Hello,

I wanted to submit a case study: I start from my need to be able to know the cost of downloaded products (with free download pro plugin).

Step1: I create a simple product "a1" with price 100.

in wp_postmeta, records are normally created, including the record with

post_id=<xxx>, meta_key="_price" and "meta_value=100.

Step2: I make a product download. records are correctly inserted in postmeta including the record with

meta_key="somdn_product_id",meta_value=<xxx>.

in the records added now there is not a record with meta_key="_price" but I can know the download price by pointing to the product record through the somdn_product_id ( <xxx>)

Step3: Now suppose you vary the product by making it a variable product through an attribute with 2 variations.

records will be created for each variation in postmeta. in each of them a record with the price will be reported.

New postmeta records will also be added with post_id=<xxx>, meta_key="_price", and meta_value

about the prices of the changes created.

now I can no longer understand the price of the downloaded products in the product download when the product was of the simple type.

this is because in its record the prices of the variations have also been added.

I do not know if I have been clear and / or I have said inaccuracies. In case the problem was real I would suggest to add at least the price of the downloaded product in the records postmeta inserted at the time of download.

this would protect against any changes to the history of the product.

  • Richard Webster

    @rwebster

    22 Jun 2022
    10:46 am

    Hi mate. Price was not factored into the tracked download post because the price to the customer is considered free.

  • carlo fattori

    @carlo_fattori

    22 Jun 2022
    11:22 am

    I understand the answer. maybe before continuing I try to describe my need that I thought to solve with the free download plugin:
    I should implement an accounting logic as follows: a company x has a number of clients. Each customer can download over time products that have a cost without going through checkout. According to variable agreements (reaching a threshold, reaching the number of downloads, etc ..) and not easily implementable through plugins (at least I have not found any) the company will be sent a report with the sum of the downloads made (number of downloads, sum of amounts,...).
    The company will then proceed to payment.
    I was thinking of implementing the accounting logic with an external application (filemaker) through a link ODBC to the worsdpress db.
    As said I understand your (logical) answer. I would only suggest that it would perhaps have been useful to insert an option with which to ask for the inclusion of the price in the configuration of the tracking section of the plugin. there is already an option with which you are asked to enable free download even to discounted products and I think this option could be useful.
    If this is not possible I will find some workarounds.

    thanks anyway for the quick answers

  • Richard Webster

    @rwebster

    22 Jun 2022
    11:37 am

    Hi mate, I understand. Adding the price to the meta data is possible. I will give you a code snippet tomorrow 🙂

  • carlo fattori

    @carlo_fattori

    27 Jun 2022
    10:30 am

    hello Richard. do you have any updates on the snippet ?

  • Richard Webster

    @rwebster

    27 Jun 2022
    10:36 am

    Morning mate, sorry for the late response. I've been at some emergency DIY all weekend. Leave it with me until tomorrow afternoon 🙂

  • Richard Webster

    @rwebster

    27 Jun 2022
    10:46 am

    Just to confirm, is the price that you want to add the price that's in the Regular Price box for the product, or the price that's calculated for the user?

  • carlo fattori

    @carlo_fattori

    27 Jun 2022
    6:05 pm

    Regular Price thanks

    I would like to ask you if the snippet can be used by me (possibly cloning the code) to add any other fields in case it is necessary. If the snippet is wired only for the price that's fine.thanks again

    Last modified: 27th June 2022, 6:06 pm by carlo fattori

  • Richard Webster

    @rwebster

    29 Jun 2022
    4:13 pm

    Afternoon mate, just need to do a little testing then it will be sorted. Expect the code tomorrow 🙂

  • Richard Webster

    @rwebster

    30 Jun 2022
    3:26 pm

    Here you go mate. This snippet will take the regular price for the product or variation that was downloaded and add it to the meta data for the tracked download.

    https://wpenhanced.com/?som_snippet_raw=14096

    I recommend adding it to your site using the Code Snippets plugin.

    Last modified: 30th June 2022, 3:26 pm by Richard Webster

  • carlo fattori

    @carlo_fattori

    2 Jul 2022
    8:49 am

    Thank you very much