Forums

[eShop Plugin] How to update price value via $_POST from a flash application? (6 posts)

  1. Michael
    Member
    Posted 1 year ago #

    So I have this flash application that sends price value to eShop Plugin. I wanted to update it dynamically using the following code:
    $wpdb->query("update wp_postmeta set meta_value = '".$meta_val."' where meta_id = 1112");
    It's working, but when I click the add to cart button, it says Error. That product is not available.

    Or is there a function in eshop that could update the price?

    Thanks.

  2. elfin
    Moderator
    Posted 1 year ago #

    The price is stored in a seraliazed array, so you need to retrieve the info, and then update and save. Something like this:

    $eshop_product=maybe_unserialize(get_post_meta( $post_id, '_eshop_product',true ));
    $numoptions=$eshopoptions['options_num'];
    for($i=1;$i<=$numoptions;$i++){
    if($_POST['eshop_price_'.$i]=='0') $_POST['eshop_price_'.$i]='0.00';
    $eshop_product['products'][$i]['price']=$_POST['eshop_price_'.$i];
    }
    update_post_meta( $id, '_eshop_product', $eshop_product);

    (crude example)

  3. Michael
    Member
    Posted 1 year ago #

    So, changing it straight from the database won't work using $wpdb->query()? :(

    Which file can I edit the function?
    Thank you so much for the help.

  4. elfin
    Moderator
    Posted 1 year ago #

    edit what function?

    No it can't be done via wpdb->query().

  5. Michael
    Member
    Posted 1 year ago #

    I mean the file where you can update the price using $_POST. Or can it be done on the single.php?

  6. elfin
    Moderator
    Posted 1 year ago #

    have a look in eshop-product-entry.php

Topic Closed

This topic has been closed to new replies.

About this Topic