WooCommerce - Updating Product through API / HTTP Requests2019 Community Moderator ElectionProduct images distorted/too large in WooCommerceForce woocommerce product variable dropdownsMake a search only field for WooCommerce productsWoocommerce API - Requests from my own front-endWooCommerce REST API Setting Product Image - WooCommerce.NetPopulating, updating custom field in WooCommerce SubscriptionsHow enable/disable WooCommerce product variation using rest API (php)?Woocommerce user registration post requestWooCommerce WordPress Hook for Bulk Stock updatePOST & UPDATE JSON data in WooCommerce from external API

Why are there no stars visible in cislunar space?

What are the consequences of changing the number of hours in a day?

Does the Shadow Magic sorcerer's Eyes of the Dark feature work on all Darkness spells or just his/her own?

Emojional cryptic crossword

Animating wave motion in water

Help with identifying unique aircraft over NE Pennsylvania

Imaginary part of expression too difficult to calculate

Why doesn't the fusion process of the sun speed up?

Is xar preinstalled on macOS?

Which partition to make active?

Why is "la Gestapo" feminine?

If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?

Why is participating in the European Parliamentary elections used as a threat?

Should a narrator ever describe things based on a characters view instead of fact?

PTIJ: Why do we make a Lulav holder?

What is the tangent at a sharp point on a curve?

Recursively updating the MLE as new observations stream in

How to read string as hex number in bash?

How to determine the greatest d orbital splitting?

How do you justify more code being written by following clean code practices?

Have the tides ever turned twice on any open problem?

Pre-Employment Background Check With Consent For Future Checks

Print last inputted byte

Output visual diagram of picture



WooCommerce - Updating Product through API / HTTP Requests



2019 Community Moderator ElectionProduct images distorted/too large in WooCommerceForce woocommerce product variable dropdownsMake a search only field for WooCommerce productsWoocommerce API - Requests from my own front-endWooCommerce REST API Setting Product Image - WooCommerce.NetPopulating, updating custom field in WooCommerce SubscriptionsHow enable/disable WooCommerce product variation using rest API (php)?Woocommerce user registration post requestWooCommerce WordPress Hook for Bulk Stock updatePOST & UPDATE JSON data in WooCommerce from external API










0















I am attempting to update WooCommerce products through notifications sent by a third party application. I have read the documentation on doing this and it seems easy enough, but it looks like the only way to use the API to update a product is by Product ID. Unfortunately, these are/were created incrementally while uploading the rather large product catalog into WooCommerce.



While making the .csv's and uploading to WooCommerce, we set the SKU's to be the same ID that the products have in the third-party software (book ISBN's). So I am able to send that number (the number that corresponds with SKU in WC) with the HTTP request, but that does not allow me to perform the product update.



It seems to me, the best way to accomplish this integration would be to change the product ID's of all my products in WooCommerce to be the same as this unique number that is currently the SKU. It doesn't appear as though this is possible to do in the dashboard or user interface, so I imagine I'll have to do it on a database level.



Does anyone know what tables will need to be modified or if there is a way to do this in the dashboard? Maybe even a tweak to my HTTP request to the API that will allow me to update by SKU?










share|improve this question


























    0















    I am attempting to update WooCommerce products through notifications sent by a third party application. I have read the documentation on doing this and it seems easy enough, but it looks like the only way to use the API to update a product is by Product ID. Unfortunately, these are/were created incrementally while uploading the rather large product catalog into WooCommerce.



    While making the .csv's and uploading to WooCommerce, we set the SKU's to be the same ID that the products have in the third-party software (book ISBN's). So I am able to send that number (the number that corresponds with SKU in WC) with the HTTP request, but that does not allow me to perform the product update.



    It seems to me, the best way to accomplish this integration would be to change the product ID's of all my products in WooCommerce to be the same as this unique number that is currently the SKU. It doesn't appear as though this is possible to do in the dashboard or user interface, so I imagine I'll have to do it on a database level.



    Does anyone know what tables will need to be modified or if there is a way to do this in the dashboard? Maybe even a tweak to my HTTP request to the API that will allow me to update by SKU?










    share|improve this question
























      0












      0








      0








      I am attempting to update WooCommerce products through notifications sent by a third party application. I have read the documentation on doing this and it seems easy enough, but it looks like the only way to use the API to update a product is by Product ID. Unfortunately, these are/were created incrementally while uploading the rather large product catalog into WooCommerce.



      While making the .csv's and uploading to WooCommerce, we set the SKU's to be the same ID that the products have in the third-party software (book ISBN's). So I am able to send that number (the number that corresponds with SKU in WC) with the HTTP request, but that does not allow me to perform the product update.



      It seems to me, the best way to accomplish this integration would be to change the product ID's of all my products in WooCommerce to be the same as this unique number that is currently the SKU. It doesn't appear as though this is possible to do in the dashboard or user interface, so I imagine I'll have to do it on a database level.



      Does anyone know what tables will need to be modified or if there is a way to do this in the dashboard? Maybe even a tweak to my HTTP request to the API that will allow me to update by SKU?










      share|improve this question














      I am attempting to update WooCommerce products through notifications sent by a third party application. I have read the documentation on doing this and it seems easy enough, but it looks like the only way to use the API to update a product is by Product ID. Unfortunately, these are/were created incrementally while uploading the rather large product catalog into WooCommerce.



      While making the .csv's and uploading to WooCommerce, we set the SKU's to be the same ID that the products have in the third-party software (book ISBN's). So I am able to send that number (the number that corresponds with SKU in WC) with the HTTP request, but that does not allow me to perform the product update.



      It seems to me, the best way to accomplish this integration would be to change the product ID's of all my products in WooCommerce to be the same as this unique number that is currently the SKU. It doesn't appear as though this is possible to do in the dashboard or user interface, so I imagine I'll have to do it on a database level.



      Does anyone know what tables will need to be modified or if there is a way to do this in the dashboard? Maybe even a tweak to my HTTP request to the API that will allow me to update by SKU?







      woocommerce






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 19:03









      Case SilvaCase Silva

      6812




      6812






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Modifiy the Product IDs in the database directly is not a good choices.
          This action is required to do every time when creating new products.



          The most simplest and safe appoach is creating a new API,
          which purpose for searching the product ID by SKU.



          Here is a part of sample code.



          function get_product_by_sku( $sku ) 
          global $wpdb;

          $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

          if ( $product_id ) return new WC_Product( $product_id );

          return null;






          share|improve this answer























          • I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

            – Case Silva
            Mar 7 at 19:49










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051068%2fwoocommerce-updating-product-through-api-http-requests%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Modifiy the Product IDs in the database directly is not a good choices.
          This action is required to do every time when creating new products.



          The most simplest and safe appoach is creating a new API,
          which purpose for searching the product ID by SKU.



          Here is a part of sample code.



          function get_product_by_sku( $sku ) 
          global $wpdb;

          $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

          if ( $product_id ) return new WC_Product( $product_id );

          return null;






          share|improve this answer























          • I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

            – Case Silva
            Mar 7 at 19:49















          0














          Modifiy the Product IDs in the database directly is not a good choices.
          This action is required to do every time when creating new products.



          The most simplest and safe appoach is creating a new API,
          which purpose for searching the product ID by SKU.



          Here is a part of sample code.



          function get_product_by_sku( $sku ) 
          global $wpdb;

          $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

          if ( $product_id ) return new WC_Product( $product_id );

          return null;






          share|improve this answer























          • I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

            – Case Silva
            Mar 7 at 19:49













          0












          0








          0







          Modifiy the Product IDs in the database directly is not a good choices.
          This action is required to do every time when creating new products.



          The most simplest and safe appoach is creating a new API,
          which purpose for searching the product ID by SKU.



          Here is a part of sample code.



          function get_product_by_sku( $sku ) 
          global $wpdb;

          $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

          if ( $product_id ) return new WC_Product( $product_id );

          return null;






          share|improve this answer













          Modifiy the Product IDs in the database directly is not a good choices.
          This action is required to do every time when creating new products.



          The most simplest and safe appoach is creating a new API,
          which purpose for searching the product ID by SKU.



          Here is a part of sample code.



          function get_product_by_sku( $sku ) 
          global $wpdb;

          $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

          if ( $product_id ) return new WC_Product( $product_id );

          return null;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 19:45









          L.C. Echo ChanL.C. Echo Chan

          506925




          506925












          • I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

            – Case Silva
            Mar 7 at 19:49

















          • I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

            – Case Silva
            Mar 7 at 19:49
















          I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

          – Case Silva
          Mar 7 at 19:49





          I'm not quite sure this would help me in my current situation, unless I'm confused. My third party application will be generating an http request on an action (such as a change in inventory quantities or a change in product pricing for example) and this will be sent to WooCommerce. The only relevant information I can send along to match the product will be the SKU number that I mentioned. Which is why I thought changing the ID would be the best option overall. It seems to me that in the future, when creating new products with .csv's, I can manually set the ID to match this number.

          – Case Silva
          Mar 7 at 19:49



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55051068%2fwoocommerce-updating-product-through-api-http-requests%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme