This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->blocks->add('cart/product/title', new Am_Block_Base(null, 'ogp-me', null, function(Am_View $v) { | |
| if ($v->displayProductDetails) { | |
| /** @var Product $product */ | |
| $product = $v->product; | |
| $product_url = $product->path ? | |
| $v->surl('product/' . urlencode($product->path), false) : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, function (Am_Event_ValidateSavedForm $event) { | |
| $form = $event->getForm(); | |
| $vars = $form->getValue(); | |
| if (isset($vars['name_f']) && isset($vars['name_l']) && $vars['name_f'] == $vars['name_l']) | |
| { | |
| $event->addError('Some Error Occurred! Please try to signup later...'); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_UPDATE, function(Am_Event_UserAfterUpdate $e) { | |
| $user = $e->getUser(); | |
| $old = $e->getOldUser(); | |
| if ($user->comment && $user->comment != $old->comment) { | |
| $note = $e->getDi()->userNoteRecord; | |
| $note->user_id = $user->pk(); | |
| $note->content = $user->comment; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(function(){ | |
| jQuery(window).resize(function(){ | |
| jQuery('iframe.embed-video-16-9').each(function(){ | |
| jQuery(this).height(jQuery(this).width() * 9/16) | |
| }); | |
| }).resize(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Use click event to add Brick to Form | |
| */ | |
| Am_Di::getInstance()->hook->add('gridSavedFormInitForm', function(Am_Event_Grid $e) { | |
| $e->getGrid()->getForm() | |
| ->addScript() | |
| ->setScript(<<<'CUT' | |
| let drag = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_COUPON, function(Am_Event $e) { | |
| $batch = $e->getCouponBatch(); | |
| $coupon = $e->getCoupon(); | |
| $used = $e->getDi()->invoiceTable->countBy([ | |
| 'coupon_id' => $coupon->pk(), | |
| 'remote_addr' => $_SERVER['REMOTE_ADDR'] | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::INVOICE_GET_CALCULATORS, function(Am_Event_InvoiceGetCalculators $e){ | |
| $e->insertBeforeTax(new class() extends Am_Invoice_Calc | |
| { | |
| public function calculate(Invoice $invoiceBill) | |
| { | |
| $discount_rules = [ | |
| 108 => [ //Product ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, function(Am_Event_AfterRender $e) { | |
| if (defined('AM_ADMIN') && AM_ADMIN) return; | |
| if ( | |
| stripos($e->getOutput(), 'There are no products available for purchase. Please come back later') !== false | |
| && $e->getDi()->request->getControllerName() == 'signup' | |
| ) { | |
| $url = $e->getDi()->url('no-product', ['c' => $e->getDi()->request->getParam('c')], false); | |
| header("Location: {$url}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function (Am_Event $e) { | |
| if (stripos($e->getTemplateName(), '/login.phtml') !== false) { | |
| $e->getView()->signup_url = '/your/custom/url'; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Am_Di::getInstance()->hook->add([Am_Event::MAIL_TEMPLATE_BEFORE_PARSE, Am_Event::MAIL_SIMPLE_TEMPLATE_BEFORE_PARSE], function(Am_Event $e) { | |
| $e->getMail()->setReturnPath('demo@example.com'); | |
| }); |