Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Shopify Delete Product

See more Shopify Examples

Delete a product from the shop.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Rest,
  Chilkat.StringBuilder;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  rest: TRest;
  sbResponse: TStringBuilder;

begin
  success := False;

  rest := TRest.Create;

  rest.SetAuthBasic('SHOPIFY_PRIVATE_API_KEY','SHOPIFY_PRIVATE_API_SECRET_KEY');

  success := rest.Connect('chilkat.myshopify.com',443,True,True);
  if (success <> True) then
    begin
      WriteLn(rest.LastErrorText);
      Exit;
    end;

  sbResponse := TStringBuilder.Create;
  success := rest.FullRequestNoBodySb('DELETE','/admin/products/#{id}.json',sbResponse);
  if (success <> True) then
    begin
      WriteLn(rest.LastErrorText);
      Exit;
    end;

  if (rest.ResponseStatusCode <> 200) then
    begin
      WriteLn('Received error response code: ' + rest.ResponseStatusCode);
      WriteLn('Response body:');
      WriteLn(sbResponse.GetAsString());
      Exit;
    end;

  WriteLn('Example Completed.');


  rest.Free;
  sbResponse.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.