PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Elements / WooAddToCart.php

WooAddToCart.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Elements/WooAddToCart.php

38 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Document\Models\Elements;
4
5 use Averta\Core\Utility\Data;
6
7 class WooAddToCart extends Button {
8
9 public function getDefaultAttributes()
10 {
11 $defaultAttributes = parent::getDefaultAttributes();
12 $product = $this->getDataSheet()['post'] ?? null;
13 if ( $product ) {
14 $defaultAttributes['data-product-id'] = $product->ID;
15 }
16
17 if ( ! empty( $this->options->canUseAjax) ) {
18 $defaultAttributes['data-can-use-ajax'] = $this->maybeReplaceDataSheetTags( $this->options->canUseAjax ) ? 'true' : 'false';
19 }
20
21 if ( ! empty( $this->options->purchasable) ) {
22 $defaultAttributes['data-purchasable'] = $this->maybeReplaceDataSheetTags( $this->options->purchasable ) ? 'true' : 'false';
23 }
24
25 if ( ! empty( $this->options->useAjax) ) {
26 $defaultAttributes['data-use-ajax'] = Data::cast( $this->options->useAjax, 'bool' ) ? 'true' : 'false';
27 }
28
29 if ( ! empty( $this->options->cartPageLabel) ) {
30 $defaultAttributes['data-added-label'] = $this->options->cartPageLabel;
31 }
32
33 $defaultAttributes['data-cart-page'] = wc_get_cart_url();
34
35 return $defaultAttributes;
36 }
37 }
38