Skip to content

Commit 4799c1f

Browse files
tegansnyderbeepci
andauthored
Add shipping label and custom label (#24)
Co-authored-by: Tegan Snyder <tsnyder@mmm.com>
1 parent b1e199d commit 4799c1f

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ foreach ($products as $product) {
5656
$shipping->setService('UPS Express');
5757
$shipping->setPrice('1300 USD');
5858
$item->setShipping($shipping);
59+
60+
// Set a custom shipping label and weight (optional)
61+
$item->setShippingLabel('ups-ground');
62+
$item->setShippingWeight('2.14');
63+
64+
// Set a custom label (optional)
65+
$item->setCustomLabel('Some Label 1', 0);
66+
$item->setCustomLabel('Some Label 2', 1);
5967

6068
// Add this product to the feed
6169
$feed->addProduct($item);

src/Product.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,46 @@ public function addShipping($shipping)
341341
return $this;
342342
}
343343

344+
/**
345+
* Add shipping label
346+
*
347+
* @param string $str
348+
*
349+
* @return $this
350+
*/
351+
public function setShippingLabel($str)
352+
{
353+
$this->setAttribute('shipping_label', $str, false);
354+
return $this;
355+
}
356+
357+
/**
358+
* Add shipping weight
359+
*
360+
* @param string $str
361+
*
362+
* @return $this
363+
*/
364+
public function setShippingWeight($str)
365+
{
366+
$this->setAttribute('shipping_weight', $str, false);
367+
return $this;
368+
}
369+
370+
/**
371+
* Set a custom label
372+
*
373+
* @param string $str
374+
* @param integer $pos
375+
*
376+
* @return $this
377+
*/
378+
public function setCustomLabel($str, $pos)
379+
{
380+
$this->setAttribute('custom_label_' . $pos, $str, false);
381+
return $this;
382+
}
383+
344384
/**
345385
* @param $namespace
346386
*

0 commit comments

Comments
 (0)