Forum Replies Created

Viewing 15 replies - 1 through 15 (of 38 total)
  • Thread Starter jobme

    (@jobme)

    Thank you Mike, I added an else statement which returns the $woo_data
    This saved the normal add to cart.

    What works horribly inconsistently though is -after clearing all sessions- when I try to add the product from scratch through this URL it tries to add it multiple times (have chosen sold individually) and prices are wrong. I do believe that something is wrong on the session part.

    Should I maybe use the hook woocommerce_get_price instead?

    Thread Starter jobme

    (@jobme)

    I’m not sure I get it right but if you mean the part “and re-add it with different ID…”, yes, I add it in the same way just using different ID & KEY in order to have a different price.

    Can I somehow pinpoint this to just product with ID 14; so at least all other products can be untouched?

    Is it the right direction at all or is it better to find another way?

    Thread Starter jobme

    (@jobme)

    Here is what I am trying to do: A fellow site makes a request to my site like this:
    https://example.com/?add-to-cart=14&REQ&id=32&key=6337

    Then if the REQ parameter exists, I crosscheck with a separate database to see the price in a table row where theID and KEY match. Then I use this price to add the custom product to cart.

    And here is the code as a separate plugin after seeing this solution:

    add_filter( 'woocommerce_add_cart_item' , 'set_woo_prices');
    add_filter( 'woocommerce_get_cart_item_from_session', 'set_session_prices', 20 , 3 );

    function set_woo_prices( $woo_data ) {
        $w_price = 999.99;
        if (isset($_GET['REQ'])) {
           $w_id = $_GET['id'];
           $w_key = $_GET['key'];
           //we ask the database
            $my_wpdb = new WPDB( 'rt', 'rt', 'db', 'localhost');
            $curr_req = $my_wpdb->get_row( "SELECT * FROM tbl WHERE id = $w_id", ARRAY_A );
            if ( $curr_req['keypin'] == $w_key ){
               $w_price = $curr_req['price'];
                }
            else {
               exit;
           }
            $woo_data['data']->set_price( $w_price );
            $woo_data['my_price'] = $w_price;
            return $woo_data;
           }
        };
    function  set_session_prices ( $woo_data , $values , $key ) {
        if ( ! isset( $woo_data['my_price'] ) || empty ( $woo_data['my_price'] ) ) { return $woo_data; }
        $woo_data['data']->set_price( $woo_data['my_price'] );
        return $woo_data;
    };

    But no… Of course it wouldn’t work:

    • If I add to cart for the first time and the ID and KEY match, I get the proper price and I’m good. If I delete the product from the cart, and re-add it with different ID, KEY and thus Price, it takes the previous price or the original from the product.
    • If I try to add any product to cart without the parameters it’s not added. If I deactivate the plugin, it works.

    For the love of God, I cannot understand what is wrong with the above code. I assume there must be something with the session but this would only explain the first point.

    Any ideas, help are highly appreciated and needed. Even if I’m in a completely wrong direction.

    Thread Starter jobme

    (@jobme)

    In essence what I need is someone to be able to click a button on another website that “knows” the price and somehow lets my site learn it, add it to cart and order it.

    Thread Starter jobme

    (@jobme)

    Thanks for the reply Mike!
    Do you believe that without the cross-check, it can be done simpler by using a product attribute value as the price?

    I found this but it’s adding a filter to show something, while I need to change the price.

    hello. would this work with a drop down as well?

    I’m trying to make astoundify’s job regions to work this way but it doesn’t.

    So maybe an approach like this one would be great.

    Thread Starter jobme

    (@jobme)

    I suspected W3 total cache too. Keep us updated with as much info as possible! Thanks

    Thread Starter jobme

    (@jobme)

    funniest fact: In dashboard, if I click on the location it sends me to google maps exactly at the spot! but it doesn’t geocode…

    Thread Starter jobme

    (@jobme)

    but at the same time, according to google I have not used a single request out of the 2500.. Any idea?

    Thread Starter jobme

    (@jobme)

    Ok, did the steps bluebananaconsulting said regarding the api and used only the second code you mention. What happened? it geolocated all previous ads but not a new one! strange, right?

    Thread Starter jobme

    (@jobme)

    guys, I admire your work. Let me test it myself and I’ll update you. Hopefully I’ll be successful too!

    Thread Starter jobme

    (@jobme)

    Hi guys, I didn’t even bother to contact them – both their plugins are not working for me and just deleted them. but the problem did not resolve. I still get the exceeded daily quota but I cannot understand why.

    The last thing I assume is that there is another site on my server (mt’s grid) that exceeds the limit all the time. But to be honest with you I cannot accept it as a valid cause – I bet all demos of wp job manager in various themes are on shared servers but work.

    Whoever finds a solution to this I would be more than happy to know it myself.

    Ok – the slug trick fixed it. Both the special chars and the spaces.

    If I’m not mistaken the way you made the job-filters removes the main search input “search-keywords”.

    On my copy I want this, so I made all the changes you made manually, and left my search-keywords intact.

    Now, no matter what i put in the search-keywords input, it displays all jobs.

    Any idea how to fix that?

    I truly appreciate the assistance you provide me with. Thank you.

    Thanks – I truly appreciate it. Have a great weekend ahead.

    ^Here you go. Thanks for the tip!

Viewing 15 replies - 1 through 15 (of 38 total)