Skip to content

Instantly share code, notes, and snippets.

View hnestmann's full-sized avatar

Holger Nestmann hnestmann

  • Salesforce
  • Jena
View GitHub Profile
@hnestmann
hnestmann / requestbody.json
Created September 19, 2023 09:47
Salesforcce Order Management Sample Request
{
"allOrNone": true,
"compositeRequest": [
{
"method": "POST",
"url": "/services/data/v58.0/sobjects/Order",
"referenceId": "refOrder",
"body": {
"Pricebook2Id": "01sHn000001aU8VIAU",
"Name": "Derek Emmett Brown",
'use strict';
exports.setApplicablePriceBooks = function () {
var CacheMgr = require('dw/system/CacheMgr');
var Site = require('dw/system/Site');
var cache = CacheMgr.getCache('customer-groups-with-pricebooks');
var cacheKey = Site.getCurrent().ID + '-customer-groups-with-pricebooks';
var customerGroupsWithPricebooks = cache.get(cacheKey, function () {
@hnestmann
hnestmann / priceChange.js
Created December 9, 2022 07:39
Job that randomizes prices to simultate operational price changes
'use strict';
/**
* Job Step Type that calculates random price changes
*
* - Covers ~25% of all products (search hits) per job run
* - Throws the dice to generate +/- 5-30% price changes
*/
const shortCode = 'abcdefgh';
const tenant = 'zzzz_001';
const clientId = '1234567-890a-bcde-f123-4567890abcd';
const clientSecret = 'secret';
const base = `https://${shortCode}.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/${tenant}/oauth2/passwordless`;
/** Start Page with a little form, where you can enter your username **/
function start() {
This file has been truncated, but you can view the full file.
{
"basePath": "/s/-/dw/shop/v22_4",
"consumes": [
"application/json",
"text/xml",
"application/xml"
],
"definitions": {
"approaching_discount": {
"description": "Document representing a note to an object.",
{
"basePath": "/",
"consumes": [
"application/json",
"text/xml",
"application/xml"
],
"definitions": {
"image": {
"properties": {
/**
* Input: Line separated SKUs (e.g grepped from catalog export), inventory export
* Output: inventory import of all 0 item items
*
* Original use case: customer shows Back-in-Stock only if item has zero item inventory, however production cleaned 0 to null removing bis
*/
const fs = require('fs');
var readlines = require('n-readlines')
// ==UserScript==
// @name Set Parcel Shop Id
// @version 1
// @grant none
// ==/UserScript==
if (window.location.href.includes('https://production-realm-customer.demandware.net/on/demandware.store/Sites-Site/')) {
function waitForElement(selector) {
return new Promise(function (resolve, reject) {
var customerPromotions = dw.campaign.PromotionMgr.getActiveCustomerPromotions();
/**
* Converts a product into a extended object
*/
function createExtendedProduct(productId) {
var staticCache = dw.system.CacheMgr.getCache('ProductExtendStatic');
var product = dw.catalog.ProductMgr.getProduct(productId);
if (!product) {
return;
<?xml version="1.0" encoding="UTF-8"?>
<shipping xmlns="http://www.demandware.com/xml/impex/shipping/2007-03-31">
<shipping-method method-id="standardDHL_DE" default="false">
<display-name xml:lang="x-default">DHL Standard</display-name>
<online-flag>true</online-flag>
<price-table>
<amount order-value="0">0.99</amount>
</price-table>
<excluded-addresses>
<included-addresses>