← back to Designer Wallcoverings

DW-Agents/dw-agents/create-why-shop-graphql.js

184 lines

const https = require('https');

const SHOPIFY_STORE = 'designer-laboratory-sandbox.myshopify.com';
const SHOPIFY_TOKEN = (process.env.SHOPIFY_ADMIN_TOKEN || '');

const pageContent = `<div style="max-width: 1200px; margin: 0 auto; padding: 40px 20px;">

  <div style="text-align: center; margin-bottom: 60px;">
    <h1 style="font-size: 48px; font-weight: 700; color: #1a1a1a; margin-bottom: 20px;">Why Shop at Designer Wallcoverings?</h1>
    <p style="font-size: 20px; color: #666; max-width: 800px; margin: 0 auto; line-height: 1.6;">America's premier destination for luxury wallcoverings, grasscloth, and designer fabrics since 2006</p>
  </div>

  <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; margin-bottom: 60px;">

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">🌟 Largest Selection Online</h3>
      <p style="color: #555; line-height: 1.8;">Browse over 50,000+ designer wallcoverings, grasscloth wallpapers, and luxury fabrics from the world's leading manufacturers.</p>
    </div>

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">💰 Best Prices Guaranteed</h3>
      <p style="color: #555; line-height: 1.8;">We offer the lowest prices on designer wallcoverings - up to 60% off retail prices with our price match guarantee.</p>
    </div>

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">📦 Free Shipping</h3>
      <p style="color: #555; line-height: 1.8;">Enjoy free standard shipping on all wallpaper orders within the continental United States.</p>
    </div>

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">🎨 Free Samples</h3>
      <p style="color: #555; line-height: 1.8;">Order up to 10 free wallpaper samples to see colors and textures in your space before committing.</p>
    </div>

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">👨‍🎨 Expert Design Support</h3>
      <p style="color: #555; line-height: 1.8;">Our in-house design team offers free consultation services. Call us at 1-888-373-4564.</p>
    </div>

    <div style="background: #f8f9fa; padding: 30px; border-radius: 12px; border-left: 4px solid #2681D5;">
      <h3 style="font-size: 24px; font-weight: 600; color: #1a1a1a; margin-bottom: 15px;">✅ Easy Returns</h3>
      <p style="color: #555; line-height: 1.8;">Hassle-free returns on unopened wallpaper within 30 days for a full refund.</p>
    </div>

  </div>

  <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 60px 40px; border-radius: 16px; color: white; margin-bottom: 60px;">
    <h2 style="font-size: 36px; font-weight: 700; text-align: center; margin-bottom: 40px;">Our Comprehensive Services</h2>

    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px;">

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">📐 Free Calculation Tool</h4>
        <p style="opacity: 0.95; line-height: 1.6;">Use our wallpaper calculator to determine exactly how many rolls you need.</p>
      </div>

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">🖼️ Visualizer Tool</h4>
        <p style="opacity: 0.95; line-height: 1.6;">Upload photos of your space and virtually try on different wallpaper patterns.</p>
      </div>

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">💻 Digital Samples</h4>
        <p style="opacity: 0.95; line-height: 1.6;">Download high-resolution digital images instantly for quick decisions.</p>
      </div>

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">🏢 Trade Program</h4>
        <p style="opacity: 0.95; line-height: 1.6;">Interior designers and contractors receive exclusive trade pricing.</p>
      </div>

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">🎓 Installation Guides</h4>
        <p style="opacity: 0.95; line-height: 1.6;">Access our library of installation videos and PDF guides for DIY success.</p>
      </div>

      <div style="background: rgba(255,255,255,0.1); padding: 25px; border-radius: 10px;">
        <h4 style="font-size: 20px; font-weight: 600; margin-bottom: 12px;">🔍 Custom Sourcing</h4>
        <p style="opacity: 0.95; line-height: 1.6;">We can source discontinued patterns or custom order special designs.</p>
      </div>

    </div>
  </div>

  <div style="margin-bottom: 60px;">
    <h2 style="font-size: 36px; font-weight: 700; text-align: center; color: #1a1a1a; margin-bottom: 30px;">Premium Brands We Carry</h2>
    <div style="background: #f8f9fa; padding: 40px; border-radius: 12px; text-align: center;">
      <p style="font-size: 16px; color: #555; line-height: 2;">
        <strong>Featured Brands:</strong> York Wallcoverings • Brewster Home Fashions • Seabrook Designs • Thibaut Design • Schumacher • Phillip Jeffries • Kravet • Cole & Son • Ralph Lauren • Kenneth James • A-Street Prints • Warner Textures • Chesapeake • and over 100 more trusted brands
      </p>
    </div>
  </div>

  <div style="background: linear-gradient(135deg, #2681D5 0%, #1a5fa8 100%); padding: 60px 40px; border-radius: 16px; text-align: center; color: white;">
    <h2 style="font-size: 42px; font-weight: 700; margin-bottom: 20px;">Ready to Transform Your Space?</h2>
    <p style="font-size: 20px; margin-bottom: 30px;">Browse our collection of 50,000+ designer wallcoverings and start your project today.</p>
    <div style="display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;">
      <a href="/collections/all" style="display: inline-block; background: white; color: #2681D5; padding: 18px 40px; border-radius: 50px; font-weight: 600; font-size: 18px; text-decoration: none;">Browse Wallpapers</a>
      <a href="/pages/order-samples" style="display: inline-block; background: transparent; color: white; padding: 18px 40px; border-radius: 50px; font-weight: 600; font-size: 18px; text-decoration: none; border: 2px solid white;">Order Free Samples</a>
    </div>
    <p style="margin-top: 30px; font-size: 16px;">Questions? Call us at <strong>1-888-373-4564</strong></p>
  </div>

</div>`;

// Escape the HTML content for GraphQL
const escapedContent = pageContent.replace(/"/g, '\\"').replace(/\n/g, '\\n');

const query = `
mutation {
  pageCreate(page: {
    title: "Why Shop at DesignerWallcoverings"
    body: "${escapedContent}"
    handle: "why-shop-at-designerwallcoverings"
    isPublished: true
  }) {
    page {
      id
      title
      handle
    }
    userErrors {
      field
      message
    }
  }
}
`;

const postData = JSON.stringify({ query });

const options = {
  hostname: SHOPIFY_STORE,
  port: 443,
  path: '/admin/api/2024-01/graphql.json',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Shopify-Access-Token': SHOPIFY_TOKEN,
    'Content-Length': Buffer.byteLength(postData)
  }
};

console.log('🚀 Creating "Why Shop at DesignerWallcoverings" page via GraphQL...\n');

const req = https.request(options, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    console.log(`Status Code: ${res.statusCode}\n`);

    try {
      const response = JSON.parse(data);

      if (response.data && response.data.pageCreate && response.data.pageCreate.page) {
        console.log('✅ ✅ ✅ SUCCESS! PAGE IS LIVE! ✅ ✅ ✅');
        console.log(`\n📄 Page ID: ${response.data.pageCreate.page.id}`);
        console.log(`📝 Page Handle: ${response.data.pageCreate.page.handle}`);
        console.log(`🔗 Page URL: ${response.data.pageCreate.page.onlineStoreUrl || 'https://www.designerwallcoverings.com/pages/' + response.data.pageCreate.page.handle}`);
        console.log(`\n🎉 The page is now LIVE!`);
      } else if (response.data && response.data.pageCreate && response.data.pageCreate.userErrors && response.data.pageCreate.userErrors.length > 0) {
        console.log('❌ ERROR:');
        console.log(JSON.stringify(response.data.pageCreate.userErrors, null, 2));
      } else {
        console.log('Response:', JSON.stringify(response, null, 2));
      }
    } catch (error) {
      console.log('Response:', data);
      console.log('Parse error:', error.message);
    }
  });
});

req.on('error', (error) => {
  console.error('❌ Request failed:', error.message);
});

req.write(postData);
req.end();