Skip to content

Instantly share code, notes, and snippets.

@jacobdubail
Created January 30, 2020 17:20
Show Gist options
  • Select an option

  • Save jacobdubail/26e79626a18237cffc8c643b7fea56ca to your computer and use it in GitHub Desktop.

Select an option

Save jacobdubail/26e79626a18237cffc8c643b7fea56ca to your computer and use it in GitHub Desktop.

Revisions

  1. jacobdubail created this gist Jan 30, 2020.
    16 changes: 16 additions & 0 deletions remove_product.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?php
    $cart_update_string = "https://" . $store_domain . "/cart?cart=update&fcsid=" . $fcsid . "&output=json";

    // loop our matches and remove
    foreach ( $matched_products as $key ) {
    $item = $cart_contents['items'][$key];
    $item_id = $item['id'];

    // starts at 0, so increment.
    $index = $key+1;

    $cart_update_string .= "&{$index}:quantity=0&{$index}:id=$item_id";
    }

    $updated_cart = wp_remote_get($cart_update_string);
    $updated_cart_contents = json_decode( wp_remote_retrieve_body( $updated_cart ), true );